Class ADI2DStencilBuilder

java.lang.Object
net.finmath.finitedifference.solvers.adi.ADI2DStencilBuilder

public class ADI2DStencilBuilder extends Object
Builds tridiagonal line matrices and exact directional operator actions for alternating direction implicit (ADI) solves for two-dimensional finite difference models.

The state variables are interpreted generically as

  • state variable 0: first spatial direction,
  • state variable 1: second 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.

This builder returns tridiagonal matrices corresponding to

(I - theta * dt * A1)
(I - theta * dt * A2)

and also provides exact applications of A1 and A2 to a flattened 2D state vector using the same coefficients.

  • Constructor Details

    • ADI2DStencilBuilder

      public ADI2DStencilBuilder(FiniteDifferenceEquityModel model, double[] x0Grid, double[] x1Grid)
      Performs the operation.
      Parameters:
      model - The value.
      x0Grid - The value.
      x1Grid - The value.
  • Method Details

    • buildFirstDirectionLineMatrix

      public TridiagonalMatrix buildFirstDirectionLineMatrix(double time, double dt, double theta, int x1Index)
      Performs the operation.
      Parameters:
      time - The value.
      dt - The value.
      theta - The value.
      x1Index - The value.
      Returns:
      The value.
    • buildSecondDirectionLineMatrix

      public TridiagonalMatrix buildSecondDirectionLineMatrix(double time, double dt, double theta, int x0Index)
      Performs the operation.
      Parameters:
      time - The value.
      dt - The value.
      theta - The value.
      x0Index - The value.
      Returns:
      The value.
    • applyFirstDirectionOperator

      public double[] applyFirstDirectionOperator(double[] u, double time)
      Performs the operation.
      Parameters:
      u - The value.
      time - The value.
      Returns:
      The value.
    • applySecondDirectionOperator

      public double[] applySecondDirectionOperator(double[] u, double time)
      Performs the operation.
      Parameters:
      u - The value.
      time - The value.
      Returns:
      The value.
    • applyFirstDirectionOperatorOnSlice

      public void applyFirstDirectionOperatorOnSlice(double[] u, double[] out, double time, int x1Index)
      Performs the operation.
      Parameters:
      u - The value.
      out - The value.
      time - The value.
      x1Index - The value.
    • applySecondDirectionOperatorOnSlice

      public void applySecondDirectionOperatorOnSlice(double[] u, double[] out, double time, int x0Index)
      Performs the operation.
      Parameters:
      u - The value.
      out - The value.
      time - The value.
      x0Index - The value.
    • getFirstDirectionCoefficients

      public ADI2DStencilBuilder.DirectionalCoefficients getFirstDirectionCoefficients(double time, int x0Index, int x1Index)
      Returns the value.
      Parameters:
      time - The value.
      x0Index - The value.
      x1Index - The value.
      Returns:
      The value.
    • getSecondDirectionCoefficients

      public ADI2DStencilBuilder.DirectionalCoefficients getSecondDirectionCoefficients(double time, int x0Index, int x1Index)
      Returns the value.
      Parameters:
      time - The value.
      x0Index - The value.
      x1Index - The value.
      Returns:
      The value.