コード例 #1
0
        private void GetEuMaChD2(string savePath, int k, List <string> listFunName, bool b = false)
        {
            Stopwatch sp = new Stopwatch();

            sp.Start();


            string tmp = "\r\n\t正在计算";

            foreach (var item in listFunName)
            {
                tmp += item + "  ";
            }
            tmp += "\r\n\t......\r\n";
            act(0, tmp);
            //Parallel.For(0, ListK.Count, (i) =>
            //{
            Dictionary <string, List <int> > dic         = new Dictionary <string, List <int> >();
            Dictionary <string, int>         dicTotalTmp = new Dictionary <string, int>();

            foreach (KeyValuePair <string, Dictionary <int, List <int> > > item in dicKtuple)
            {
                dic.Add(item.Key, item.Value[k]);
                dicTotalTmp.Add(item.Key, dicTotal[item.Key][k]);
            }
            DissimiliratyEuMaChD2 d = new DissimiliratyEuMaChD2(dic, dicTotalTmp, savePath, listFunName, k);

            d.GetDissimiliratyMatrix(b);
            act(listFunName.Count, "");
            //});

            sp.Stop();
            act(0, "\tk = " + k + " 计算完毕,用时 " + sp.ElapsedMilliseconds * 1.0 / 1000 + " s\r\n\r\n");
        }
コード例 #2
0
        private void GetEuMaChD2(string savePath, bool b = false)
        {
            Stopwatch sp = new Stopwatch();

            sp.Start();

            List <string> listFunName = new List <string>();

            foreach (string item in ListFun)
            {
                if (item == "Eu" || item == "Ma" || item == "Ch" || item == "D2")
                {
                    listFunName.Add(item);
                }
            }
            string tmp = "\r\n\t正在计算";

            foreach (var item in listFunName)
            {
                tmp += item + "  ";
            }
            tmp += "\r\n\t......\r\n";
            act(0, tmp);
            Parallel.For(0, ListK.Count, (i) =>
            {
                Dictionary <string, List <int> > dic = new Dictionary <string, List <int> >();
                Dictionary <string, int> dicTotalTmp = new Dictionary <string, int>();
                foreach (KeyValuePair <string, Dictionary <int, List <int> > > item in dicKtuple)
                {
                    dic.Add(item.Key, item.Value[listK[i]]);
                    dicTotalTmp.Add(item.Key, dicTotal[item.Key][listK[i]]);
                }
                DissimiliratyEuMaChD2 d = new DissimiliratyEuMaChD2(dic, dicTotalTmp, savePath, listFunName, ListK[i]);
                d.GetDissimiliratyMatrix(b);
                act(listFunName.Count, "");
            });

            sp.Stop();
            act(0, "\t计算完毕,用时 " + sp.ElapsedMilliseconds * 1.0 / 1000 + " s\r\n\r\n");
        }