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); }
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()); } }
public VilenkinTransform(ExpansionBase expansionBase, List <Complex> coeffs) { this.coeffs = coeffs; vilenkinFunctions = new Dictionary <int, VilenkinFunction>(); for (int i = 0; i < coeffs.Count; i++) { vilenkinFunctions.Add(i, new VilenkinFunction(expansionBase, new ParyN(expansionBase, i))); } }
public VilenkinFunction(ExpansionBase expBase, ParyN n) { Rj = new List <RademacherFunction>(); List <int> notZeroIndexes = n.GetNotZeroCoeffs(); foreach (int j in notZeroIndexes) { Rj.Add(new RademacherFunction(expBase, j)); } ExpBase = expBase; this.n = n; }
public static Complex[,] BuildRadamacher(ExpansionBase expBase, ParyX[] intervals, int k) { int N = intervals.Length; Complex[,] matrix = new Complex[N, N]; RademacherFunction r = new RademacherFunction(expBase, k); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { matrix[i, j] = r.Value(intervals[i], j); } } return(matrix); }
public ParyN(ExpansionBase expansionBase, int n) { expansion = new List <int>(expansionBase.GetK()); ArrayUtils.Fill(expansion, 0, expansionBase.GetK()); int i = 0; int r; int k = n; while (k != 0) { r = k % expansionBase.Pk(i); k = k / expansionBase.Pk(i); expansion.RemoveAt(i); expansion.Insert(i, r); i++; } }
public static Complex[,] BuildVilenkin(ExpansionBase expBase, ParyX[] intervals) { int N = intervals.Length; Complex[,] matrix = new Complex[N, N]; VilenkinFunction[] ws = new VilenkinFunction[N]; for (int i = 0; i < N; i++) { ws[i] = new VilenkinFunction(expBase, new ParyN(expBase, i)); } for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { matrix[i, j] = ws[j].Value(intervals[i]); } } return(matrix); }
public RademacherFunction(ExpansionBase expBase, int k) { this.k = k; Pk = expBase.Pk(k); values = new Dictionary <int, Dictionary <int, Complex> >(); }
public ParyXBuilder(ExpansionBase expansionBase, int roundDecimals) { this.expansionBase = expansionBase; this.roundDecimals = roundDecimals; }