Class GridWithMandatoryPoint
java.lang.Object
net.finmath.finitedifference.grids.AbstractGrid
net.finmath.finitedifference.grids.GridWithMandatoryPoint
- All Implemented Interfaces:
Grid
Piecewise-uniform grid on
[minimumValue, maximumValue] with one
mandatory interior node.
The interval is split into two sub-intervals:
[minimumValue, mandatoryPoint][mandatoryPoint, maximumValue]
On each side, nodes are distributed uniformly. The mandatory point is forced to be an exact grid node, while the lower and upper bounds are preserved.
This is useful for finite-difference pricing of products with a payoff discontinuity or kink at a known location, for example digitals with discontinuity at the strike.
- Author:
- Alessandro Gnoatto
-
Constructor Summary
ConstructorsConstructorDescriptionGridWithMandatoryPoint(int numberOfSteps, double minimumValue, double maximumValue, double mandatoryPoint) Creates a grid with one mandatory interior node. -
Method Summary
Modifier and TypeMethodDescriptionstatic intfindMandatoryIndex(double[] grid, double mandatoryPoint) Finds the index of a mandatory point in a previously generated grid.static intfindMandatoryIndex(Grid grid, double mandatoryPoint) Convenience overload.double[]getDelta(double[] vector) Returns the spacing between consecutive grid points.double[]getGrid()Returns the grid points, generating them if necessary.intReturns the node index corresponding to the mandatory point.doubleReturns the mandatory point.Methods inherited from class AbstractGrid
getInteriorGrid
-
Constructor Details
-
GridWithMandatoryPoint
public GridWithMandatoryPoint(int numberOfSteps, double minimumValue, double maximumValue, double mandatoryPoint) Creates a grid with one mandatory interior node.- Parameters:
numberOfSteps- Number of grid intervals.minimumValue- Lower grid boundary.maximumValue- Upper grid boundary.mandatoryPoint- Point that must appear exactly as a grid node.
-
-
Method Details
-
getGrid
public double[] getGrid()Returns the grid points, generating them if necessary.- Returns:
- The grid points.
-
getDelta
public double[] getDelta(double[] vector) Returns the spacing between consecutive grid points.- Parameters:
vector- Array of values at grid points, usually the grid itself.- Returns:
- The spacing array.
-
getMandatoryPoint
public double getMandatoryPoint()Returns the mandatory point.- Returns:
- The mandatory point.
-
getMandatoryIndex
public int getMandatoryIndex()Returns the node index corresponding to the mandatory point.- Returns:
- The mandatory node index.
-
findMandatoryIndex
public static int findMandatoryIndex(double[] grid, double mandatoryPoint) Finds the index of a mandatory point in a previously generated grid.- Parameters:
grid- The grid array.mandatoryPoint- The mandatory point.- Returns:
- The index of the mandatory point.
-
findMandatoryIndex
Convenience overload.- Parameters:
grid- The grid.mandatoryPoint- The mandatory point.- Returns:
- The index of the mandatory point.
-