예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
 public double GetBasis(double x, int index)
 {
     return(DeBoorMethods.DeBoorB(x, grid, degree, index));
 }
예제 #9
0
 public Matrix GetMatrix()
 {
     return(DeBoorMethods.SlowCreateInterpolationMatrix(grid, degree));
 }