Exemplo n.º 1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            ExpansionBase expansionBase = new ExpansionBase(p);

            int K = 1;

            ParyX[] xs = ConstIntervalsUtils.Intervals(expansionBase, K);
            int     P  = p.ElementAt(K);

            Complex[] function = ConstIntervalsUtils.BuildConstFunc(xs);
            Complex[,] B;
            Complex[,] conjugatedRademacherMatrix;
            Complex[,] rademacherMatrix;
            Complex[,] FkValues = new Complex[expansionBase.Mk(K), P];
            Complex N = new Complex(1d / p.ElementAt(K), 0);

            ParyX[]   subXs;
            Complex[] X;
            Complex[,] XMatrix;
            for (int i = 0; i < expansionBase.Mk(K); i++)
            {
                subXs                      = ArrayUtils.SubArray(xs, i * P, P);
                rademacherMatrix           = MatrixUtils.BuildRadamacher(expansionBase, subXs, K);
                conjugatedRademacherMatrix = MatrixUtils.Conjugate(rademacherMatrix);
                MatrixUtils.Multiply(conjugatedRademacherMatrix, N);
                B       = MatrixUtils.ToMatrix(ArrayUtils.SubArray(function, i * P, P));
                XMatrix = MatrixUtils.Multiply(conjugatedRademacherMatrix, B);
                X       = ArrayUtils.ToArray(XMatrix);
                MatrixUtils.InsertVectorToMatrix(FkValues, X, i);
            }
            ParyX[] vilenkinXs = ConstIntervalsUtils.Intervals(expansionBase, K - 1);
            Complex[,] vilenkinMatrix    = MatrixUtils.BuildVilenkin(expansionBase, vilenkinXs);
            Complex[,] conjugatedWMatrix = MatrixUtils.Conjugate(vilenkinMatrix);
            Complex WN = new Complex(1d / expansionBase.Mk(K), 0);

            MatrixUtils.Multiply(conjugatedWMatrix, WN);
            List <Complex> coeffs = new List <Complex>();

            Complex[,] C;
            for (int i = 0; i < P; i++)
            {
                B = MatrixUtils.ColumnAsMatrix(FkValues, i);
                C = MatrixUtils.Multiply(conjugatedWMatrix, B);
                ArrayUtils.AddAll(ArrayUtils.ToArray(C), coeffs);
            }
            VilenkinTransform transform          = new VilenkinTransform(expansionBase, coeffs);
            List <Complex>    zeroCoeffs         = TransformUtils.ZeroByPercent(coeffs, 50);//процент обнуления коэффициентов
            VilenkinTransform transformWithZeros = new VilenkinTransform(expansionBase, zeroCoeffs);

            AddSeries(SeriesName, SeriesChartType.Line, Color.Empty);
            AddSeries(TransformSeriesName, SeriesChartType.Point, Color.Red);
            ConfigGraph();
            chart.Series[SeriesName].ChartArea          = gridName;
            chart.Series[TransformSeriesName].ChartArea = gridName;
            for (int i = 0; i < xs.Length; i++)
            {
                chart.Series[SeriesName].Points.AddXY(xs[i].GetX(), transform.Value(xs[i]).GetRe());
                chart.Series[TransformSeriesName].Points.AddXY(xs[i].GetX(), transformWithZeros.Value(xs[i]).GetRe());
            }
        }
Exemplo n.º 2
0
        public static ParyX[] Intervals(ExpansionBase expBase, int k)
        {
            ParyXBuilder xBuilder = new ParyXBuilder(expBase, 13);
            int          N        = expBase.Mk(k + 1);

            ParyX[] xs = new ParyX[N];
            decimal dN = new decimal(N);

            int[] exp     = new int[k + 1];
            int   current = k;

            xs[0] = xBuilder.Build(exp, new decimal(0) / dN);
            for (int j = 1; j < N; j++)
            {
                exp[current]++;
                while (exp[current] == expBase.Pk(current))
                {
                    exp[current--] = 0;
                    exp[current]++;
                }
                current = k;
                xs[j]   = xBuilder.Build(exp, new decimal(j) / dN);
            }
            return(xs);
        }