예제 #1
0
        public void regrid(Vector new_grid, Func <double, double> func)
        {
            Vector transformed_grid = new Vector(grid_.Count);

            for (int i = 0; i < grid_.Count; i++)
            {
                transformed_grid[i] = func(grid_[i]);
            }

            CubicInterpolation priceSpline = new CubicInterpolation(transformed_grid, transformed_grid.Count, values_,
                                                                    CubicInterpolation.DerivativeApprox.Spline, false,
                                                                    CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0,
                                                                    CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0);

            priceSpline.update();

            Vector newValues = (Vector)new_grid.Clone();

            for (int i = 0; i < grid_.Count; i++)
            {
                newValues[i] = func(newValues[i]);
            }

            for (int j = 0; j < grid_.Count; j++)
            {
                newValues[j] = priceSpline.value(newValues[j], true);
            }

            values_ = newValues;
            grid_   = (Vector)new_grid.Clone();
        }
예제 #2
0
        public void regrid(Vector new_grid)
        {
            CubicInterpolation priceSpline = new CubicInterpolation(grid_, grid_.Count, values_,
                                                                    CubicInterpolation.DerivativeApprox.Spline, false,
                                                                    CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0,
                                                                    CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0);

            priceSpline.update();
            Vector newValues = new Vector(new_grid.Count);

            for (int i = 0; i < new_grid.Count; i++)
            {
                newValues[i] = priceSpline.value(new_grid[i], true);
            }

            values_ = newValues;
            grid_   = (Vector)new_grid.Clone();
        }
예제 #3
0
        public void regrid(Vector new_grid)
        {
            CubicInterpolation priceSpline = new CubicInterpolation(grid_, grid_.Count, values_,
                                                                    CubicInterpolation.DerivativeApprox.Spline, false,
                                                                    CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0,
                                                                    CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0);
            priceSpline.update();
            Vector newValues = new Vector(new_grid.Count);

            for (int i = 0; i < new_grid.Count; i++)
                newValues[i] = priceSpline.value(new_grid[i], true);

            values_ = newValues;
            grid_ = (Vector)new_grid.Clone();
        }
예제 #4
0
        public void regrid(Vector new_grid, Func<double, double> func)
        {
            Vector transformed_grid = new Vector(grid_.Count);

            for (int i = 0; i < grid_.Count; i++)
                transformed_grid[i] = func(grid_[i]);

            CubicInterpolation priceSpline = new CubicInterpolation(transformed_grid, transformed_grid.Count, values_,
                                                                    CubicInterpolation.DerivativeApprox.Spline, false,
                                                                    CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0,
                                                                    CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0);
            priceSpline.update();

            Vector newValues = (Vector)new_grid.Clone();

            for (int i = 0; i < grid_.Count; i++)
                newValues[i] = func(newValues[i]);

            for (int j = 0; j < grid_.Count; j++)
                newValues[j] = priceSpline.value(newValues[j], true);

            values_ = newValues;
            grid_ = (Vector)new_grid.Clone();
        }