Пример #1
0
        private string func2(int nstart, List<cpolinom> pols, List<BigInteger> N, int w, int a, int b, flag f, MPower pow, MInverse inv)
        {
            string s = "";
            for (int i = nstart; i < N.Count; i++)
            {
                int sum = 0;
                Stopwatch stw = new Stopwatch();

                for (int j = 1; j < pols.Count; j++)
                {
                    List<cpolinom> temp = new List<cpolinom>();
                    temp.Add(pols[0]);
                    temp.Add(pols[j]);

                    stw.Start();
                    pow.pow(pols, N[i], w, a, b, inv.inv);
                    stw.Stop();

                    sum += (int)stw.ElapsedTicks / 10;
                    stw.Reset();
                }
                int res = (int)sum / (pols.Count - 1);
                s = s + res.ToString() + ";";

                if (act.Value == false)
                {
                    Action action = () =>
                    {
                        listBox4.Items.Add("Stoped");
                        listBox4.Update();
                    };
                    Invoke(action);

                    StreamWriter sw = new StreamWriter("Temp\\N.txt");
                    sw.WriteLine(i + 1);
                    for (int j = 0; j < N.Count; j++)
                        sw.WriteLine(N[j]);
                    sw.Close();

                    break;
                }
            }
            return s;
        }
Пример #2
0
        private string func1(int ii, int wstart, int astart, int bstart, int nstart, List<cpolinom> pols, List<BigInteger> N, List<int> W, List<int> A, List<int> B, flag f, MPower pow, MInverse inv)
        {
            string s = "";
            for (int i = 0; i < N.Count; i++)
                s = s + ";" + N[i];            

            if (isWindow(ii) == true)
            {
                for (int w = wstart; w < W.Count; w++)
                {
                    s = s + "\n";
                    s = s + W[w] + ";";
                    s = s + func2(nstart, pols, N, W[w], 0, 0, f, pow, inv);                    
                    nstart = 0;
                    if (act.Value == false)
                    {
                        StreamWriter sw = new StreamWriter("Temp\\B.txt");
                        sw.WriteLine(0);
                        for (int j = 0; j < B.Count; j++)
                            sw.WriteLine(B[j]);
                        sw.Close();

                        sw = new StreamWriter("Temp\\A.txt");
                        sw.WriteLine(0);
                        for (int j = 0; j < A.Count; j++)
                            sw.WriteLine(A[j]);
                        sw.Close();

                        sw = new StreamWriter("Temp\\W.txt");
                        sw.WriteLine(w);
                        for (int j = 0; j < W.Count; j++)
                            sw.WriteLine(W[j]);
                        sw.Close();

                        break;
                    }
                }
            }
            else if (ii == 19 || ii == 20)
            {
                int ast = astart;
                int bst = bstart;

                for (int a = ast; a < A.Count; a++)
                {
                    for (int b = bst; b < B.Count; b++)
                    {
                        s = s + "\n";
                        s = s + "A:" + A[a] + ",B:" + B[b] + ";";
                        s = s + func2(nstart, pols, N, 0, A[a], B[b], f, pow, inv);                        
                        nstart = 0;

                        if (act.Value == false)
                        {
                            StreamWriter sw = new StreamWriter("Temp\\B.txt");
                            sw.WriteLine(b);
                            for (int j = 0; j < B.Count; j++)
                                sw.WriteLine(B[j]);
                            sw.Close();

                            sw = new StreamWriter("Temp\\A.txt");
                            sw.WriteLine(a);
                            for (int j = 0; j < A.Count; j++)
                                sw.WriteLine(A[j]);
                            sw.Close();

                            sw = new StreamWriter("Temp\\W.txt");
                            sw.WriteLine(0);
                            for (int j = 0; j < W.Count; j++)
                                sw.WriteLine(W[j]);
                            sw.Close();

                            break;
                        }                        
                    }
                    bst = 0;
                    if (act.Value == false)                    
                        break;                    
                }
                ast = 0;
            }
            else
            {
                s = s + "\n" + ";";
                s = s + func2(nstart, pols, N, 0, 0, 0, f, pow, inv);
                nstart = 0;
                if (act.Value == false)
                {
                    StreamWriter sw = new StreamWriter("Temp\\B.txt");
                    sw.WriteLine(0);
                    for (int j = 0; j < B.Count; j++)
                        sw.WriteLine(B[j]);
                    sw.Close();

                    sw = new StreamWriter("Temp\\A.txt");
                    sw.WriteLine(0);
                    for (int j = 0; j < A.Count; j++)
                        sw.WriteLine(A[j]);
                    sw.Close();

                    sw = new StreamWriter("Temp\\W.txt");
                    sw.WriteLine(0);
                    for (int j = 0; j < W.Count; j++)
                        sw.WriteLine(W[j]);
                    sw.Close();
                }
            }
            return s;
        }