public static Vector SimpleInterpolate(Vector y_knots, Grid grid, int deg) { if (deg == 2) { return(y_knots); } int p = grid.SplineDegree; int N = grid.Count - 2 * (p - 1) - 2 * (p - 2); Matrix A = new Matrix(N); Vector coefs = new Vector(); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { A[i, j] = DeBoorMethods.SimpleDeBoorB(grid.GetOrigin(i), grid, deg, j + p - 1); } } if (A.Length.n < 15) { Console.WriteLine(A); } coefs = Solver.BCGSTAB(A, y_knots, EPS); return(coefs); }
public double FastCalculateSpline(double x) { double S = 0d; if (x < grid.Left || x > grid.Right) { return(0); //если не лежит в отрезке то 0 } int J = grid.Find(x); int p = degree - 1; int index = J - grid.BeginIndex; if (Math.Abs(x - grid.Left) < EPS) { return(C[0]); } if (Math.Abs(x - grid.Right) < EPS) { return(C.Last); } Vector b = DeBoorMethods.bsplv(x, grid, degree, J); for (int i = 0; i < degree && index + i < C.Length; i++) { S += C[index + i] * b[i]; } return(S); }
public static Vector InterpolatePeriodic(Vector y_knots, Grid grid, int deg) { if (deg == 2) { return(y_knots); } Matrix A = DeBoorMethods.SlowCreateInterpolationPeriodicMatrix(grid, deg); int size = deg - 1; Vector spline = new Vector(size); for (int i = 0; i < size; i++) { spline[i] = A[2, i]; } int GridSize = y_knots.Length; A[0, GridSize - 2] = spline[0]; A[0, GridSize - 1] = spline[1]; A[1, GridSize - 1] = spline[0]; A[GridSize - 2, 0] = spline[0]; A[GridSize - 1, 0] = spline[1]; A[GridSize - 1, 1] = spline[0]; Console.WriteLine(A); Vector coefs = Solver.BCGSTAB(A, y_knots, EPS); return(coefs); }
public Vector GetAllBasis(double x) { Vector B = new Vector(grid.OriginalCount); for (int i = 0; i < B.Length; i++) { B[i] = DeBoorMethods.DeBoorB(x, grid, degree, i); } return(B); }
public Vector GetVectorBasis(Vector x_knots, int index) { Vector f = new Vector(x_knots.Length); for (int i = 0; i < f.Length; i++) { f[i] = DeBoorMethods.DeBoorB(x_knots[i], grid, degree, index); } return(f); }
public double SlowCalculateSpline(double x) { double S = 0d; double B = 0; for (int i = 0; i < C.Length; i++) { B = DeBoorMethods.DeBoorB(x, grid, degree, i); S += C[i] * B; } return(S); }
public static Vector Interpolate(Vector y_knots, Grid grid, int deg) { if (deg == 2) { return(y_knots); } Matrix A = DeBoorMethods.SlowCreateInterpolationMatrix(grid, deg); Console.WriteLine(A); Vector coefs = Solver.BCGSTAB(A, y_knots, EPS); return(coefs); }
public double GetBasis(double x, int index) { return(DeBoorMethods.DeBoorB(x, grid, degree, index)); }
public Matrix GetMatrix() { return(DeBoorMethods.SlowCreateInterpolationMatrix(grid, degree)); }