Exemple #1
0
        private async Task rad1Async()
        {
            SimpleBeginAboutChart();
            progressBar1.Value = 0;

            double tmin = абКонсоль.polesBeg, tmax = абКонсоль.polesEnd, eps = абКонсоль.epsroot, step = абКонсоль.steproot;
            double beg = Convert.ToDouble(textBox4.Text), end = Convert.ToDouble(textBox5.Text);

            FuncMethods.Optimization.EPS  = eps;
            FuncMethods.Optimization.STEP = step;
            int    itcount = абКонсоль.countroot, k = Convert.ToInt32(numericUpDown1.Value);
            double h = (end - beg) / (k - 1);

            mas            = new Vectors[k];
            masN           = new Vectors[k];
            args           = new double[k];
            prbar          = new int[k];
            timer1.Enabled = true;

            int ind = listBox2.SelectedIndex;

            await Task.Run(() =>
            {
                Parallel.For(0, k, (int i) =>
                {
                    args[i] = beg + i *h;
                    ComplexFunc del;

                    switch (ind)
                    {
                    case 0:
                        del = (Complex a) => Deltass(a, args[i]);
                        break;

                    case 1:
                        del = (Complex a) => K(a, 1, 0, args[i])[2, 2].Reverse();
                        break;

                    case 2:
                        del = (Complex a) => K(a, 1, 0, args[i]).Track.Reverse();
                        break;

                    default:
                        del = (Complex a) => K(a, 1, 0, args[i]).Det.Reverse();
                        break;
                    }

                    if (!half)
                    {
                        mas[i] = Roots.OtherMethod(del, tmin, tmax, step, eps, method, checkBox4.Checked, countpoles: 2);
                    }
                    else
                    {
                        mas[i] = FuncMethods.Optimization.Halfc(del, tmin, tmax, step, eps, itcount).DoubleMas.Where(n => del(n).Abs < eps).Distinct().ToArray();
                    }
                    //использовать ли корни N
                    masN[i] = DeltassNPosRoots(args[i], tmin, tmax);

                    prbar[i] = 1;
                });
            });

            ReDraw();
        }