Class ADI3DStencilBuilder
The state variables are interpreted generically as
- state variable 0: first spatial direction,
- state variable 1: second spatial direction,
- state variable 2: third spatial direction.
The PDE operator is split into the directional parts
A1: drift and diffusion terms in the first spatial direction,A2: drift and diffusion terms in the second spatial direction,A3: drift and diffusion terms in the third spatial direction.
This builder returns the tridiagonal matrix corresponding to
(I - theta * dt * A1)
on one fixed slice of the second and third state variables, or
(I - theta * dt * A2)
on one fixed slice of the first and third state variables, or
(I - theta * dt * A3)
on one fixed slice of the first and second state variables.
The coefficients are obtained from the model drift and factor loading and are discretized by central finite differences on possibly non-uniform grids.
- Author:
- Alessandro Gnoatto
-
Constructor Summary
ConstructorsConstructorDescriptionADI3DStencilBuilder(FiniteDifferenceEquityModel model, double[] x0Grid, double[] x1Grid, double[] x2Grid) Creates a stencil builder for three-dimensional ADI line solves. -
Method Summary
Modifier and TypeMethodDescriptionbuildFirstDirectionLineMatrix(double time, double dt, double theta, int x1Index, int x2Index) Builds the tridiagonal matrix for the implicit solve in the first spatial direction on a fixed slice of the second and third state variables.buildSecondDirectionLineMatrix(double time, double dt, double theta, int x0Index, int x2Index) Builds the tridiagonal matrix for the implicit solve in the second spatial direction on a fixed slice of the first and third state variables.buildThirdDirectionLineMatrix(double time, double dt, double theta, int x0Index, int x1Index) Builds the tridiagonal matrix for the implicit solve in the third spatial direction on a fixed slice of the first and second state variables.
-
Constructor Details
-
ADI3DStencilBuilder
public ADI3DStencilBuilder(FiniteDifferenceEquityModel model, double[] x0Grid, double[] x1Grid, double[] x2Grid) Creates a stencil builder for three-dimensional ADI line solves.- Parameters:
model- The finite difference model providing drift and factor loadings.x0Grid- The grid for the first state variable.x1Grid- The grid for the second state variable.x2Grid- The grid for the third state variable.
-
-
Method Details
-
buildFirstDirectionLineMatrix
public TridiagonalMatrix buildFirstDirectionLineMatrix(double time, double dt, double theta, int x1Index, int x2Index) Builds the tridiagonal matrix for the implicit solve in the first spatial direction on a fixed slice of the second and third state variables.The returned matrix represents
(I - theta * dt * A1)
where
A1contains only first-direction drift and diffusion terms.- Parameters:
time- The running time at which coefficients are evaluated.dt- The time step size.theta- The ADI weight.x1Index- The fixed index in the second state-variable grid.x2Index- The fixed index in the third state-variable grid.- Returns:
- The tridiagonal matrix for the first-direction implicit line solve.
-
buildSecondDirectionLineMatrix
public TridiagonalMatrix buildSecondDirectionLineMatrix(double time, double dt, double theta, int x0Index, int x2Index) Builds the tridiagonal matrix for the implicit solve in the second spatial direction on a fixed slice of the first and third state variables.The returned matrix represents
(I - theta * dt * A2)
where
A2contains only second-direction drift and diffusion terms.- Parameters:
time- The running time at which coefficients are evaluated.dt- The time step size.theta- The ADI weight.x0Index- The fixed index in the first state-variable grid.x2Index- The fixed index in the third state-variable grid.- Returns:
- The tridiagonal matrix for the second-direction implicit line solve.
-
buildThirdDirectionLineMatrix
public TridiagonalMatrix buildThirdDirectionLineMatrix(double time, double dt, double theta, int x0Index, int x1Index) Builds the tridiagonal matrix for the implicit solve in the third spatial direction on a fixed slice of the first and second state variables.The returned matrix represents
(I - theta * dt * A3)
where
A3contains only third-direction drift and diffusion terms.- Parameters:
time- The running time at which coefficients are evaluated.dt- The time step size.theta- The ADI weight.x0Index- The fixed index in the first state-variable grid.x1Index- The fixed index in the second state-variable grid.- Returns:
- The tridiagonal matrix for the third-direction implicit line solve.
-