public static Vector StartCardinalInterpolation(Vector y_knots, int degree, double h) { int N = y_knots.Length; int p = degree; Vector b = new Vector(2 * N + p - 2); for (int i = 0; i < N; i++) { b[i] = y_knots[i]; } Vector I = Integrate(y_knots, degree, h); for (int i = N; i < b.Length; i++) { b[i] = I[i - N]; } Matrix A = Create_LagrangeInterpolationMatrix(degree, h, N); // double EPS = 0.0000001d; Vector coefs = Solver.BCGSTAB((Matrix.Transpose(A)) * A, (Matrix.Transpose(A)) * b, EPS); Vector c = new Vector(N + p - 2); for (int i = 0; i < c.Length; i++) { c[i] = coefs[i]; } return(c); }
public static Vector GetCoef_2h(int degree) { double[] ksi = GetCardinalValue(degree, 1d); Matrix A = new Matrix(degree + 1); Vector y = new Vector(degree + 1); for (int i = 0; i < y.Length; i++) { y[i] = CardinalSpline.Cardinal(degree, i + 1, 0d, 2d); } for (int i = 0; i < degree + 1; i++) { for (int j = 0; j < ksi.Length; j++) { if (i - j >= 0) { A[i, i - j] = ksi[ksi.Length - 1 - j]; } } } Matrix A_t = Matrix.Transpose(A); Console.WriteLine("y = " + y); Console.WriteLine("A_T*A = " + A); Vector c = new Vector(); c = Solver.BCGSTAB(A, y, 0.0000001d); Console.WriteLine("SUM c = " + MyMath.Basic.SumArray(c.ToArray)); return(c); }
public static Vector Interpolate_By_CardinalSpline(Vector y_knots, int degree, double h) { int N = y_knots.Length; int p = degree; Vector b = new Vector(2 * N + p - 2); for (int i = 0; i < N; i++) { b[i] = y_knots[i]; } Vector I = CalculateSkal(y_knots, degree, h); for (int i = N; i < b.Length; i++) { b[i] = I[i - N]; } Matrix A = Create_LagrangeInterpolationMatrix(degree, h, N); // double EPS = 0.0000001d; Vector coefs = Solver.BCGSTAB((Matrix.Transpose(A)) * A, (Matrix.Transpose(A)) * b, EPS); //Console.WriteLine("b = " + b); //Console.WriteLine("A*c - b" + (A*coefs- b)); Vector c = new Vector(N + p - 2); for (int i = 0; i < c.Length; i++) { c[i] = coefs[i]; } return(c); }
public static Vector Interpolate(Vector y_knots, int degree, double h) { Vector b = new Vector(2 * y_knots.Length); for (int i = 0; i < y_knots.Length; i++) { b[i] = y_knots[i]; } Matrix A = MinInterpolationMatrix(degree, h, y_knots.Length); //Console.WriteLine(A); double EPS = 0.000001d; Vector coefs = Solver.BCGSTAB(A, b, EPS); return(coefs); }