示例#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();
        }
      public override double value(double x, double y) 
      {
         List<double> section = new InitializedList<double>( splines_.Count );
         for (int i=0; i<splines_.Count; i++)
            section[i]=splines_[i].value(x,true);

         CubicInterpolation spline = new CubicInterpolation(this.yBegin_, this.ySize_, section,
                                                            CubicInterpolation.DerivativeApprox.Spline, false,
                                                            CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0,
                                                            CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0);
         return spline.value(y,true);
      }
        public override double value(double x, double y)
        {
            List <double> section = new InitializedList <double>(splines_.Count);

            for (int i = 0; i < splines_.Count; i++)
            {
                section[i] = splines_[i].value(x, true);
            }

            CubicInterpolation spline = new CubicInterpolation(this.yBegin_, this.ySize_, section,
                                                               CubicInterpolation.DerivativeApprox.Spline, false,
                                                               CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0,
                                                               CubicInterpolation.BoundaryCondition.SecondDerivative, 0.0);

            return(spline.value(y, true));
        }
示例#4
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();
        }
示例#5
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();
        }
示例#6
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();
        }