Class ThetaMethod1DAssembly

java.lang.Object
net.finmath.finitedifference.solvers.ThetaMethod1DAssembly

public final class ThetaMethod1DAssembly extends Object
Shared matrix-free assembly utilities for one-dimensional theta-method finite-difference solvers.

This class is primarily numerical: it assembles the one-dimensional spatial operator directly into tridiagonal coefficients.

The generic assembly methods work with arrays for drift, variance, and local discount / reaction coefficients, which allows state-dependent reaction terms as required for interest-rate PDEs.

For backward compatibility with equity-only solvers using deterministic discounting, the class also provides convenience methods based on a scalar short rate.

Author:
Alessandro Gnoatto
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    Container for model coefficients on a one-dimensional grid in the deterministic-rate equity case.
  • Method Summary

    Modifier and Type
    Method
    Description
    static double[]
    apply(TridiagonalMatrix matrix, double[] vector)
    Applies a tridiagonal operator to a vector.
    buildModelCoefficients(net.finmath.finitedifference.assetderivativevaluation.models.FiniteDifferenceEquityModel model, double[] xGrid, double time)
    Compatibility method for equity-only solvers with deterministic discounting.
    static void
    buildThetaLeftHandSide(TridiagonalMatrix lhs, double[] xGrid, double[] drift, double[] variance, double[] localDiscountRate, double deltaTau, double theta)
    Builds the left-hand side matrix for the theta step:
    static void
    buildThetaLeftHandSide(TridiagonalMatrix lhs, double[] xGrid, double[] drift, double[] variance, double shortRate, double deltaTau, double theta)
    Compatibility overload for deterministic-rate solvers.
    static void
    buildThetaRightHandSide(TridiagonalMatrix rhsOperator, double[] xGrid, double[] drift, double[] variance, double[] localDiscountRate, double deltaTau, double theta)
    Builds the right-hand side operator for the theta step:
    static void
    buildThetaRightHandSide(TridiagonalMatrix rhsOperator, double[] xGrid, double[] drift, double[] variance, double shortRate, double deltaTau, double theta)
    Compatibility overload for deterministic-rate solvers.
    static double
    getShortRate(net.finmath.finitedifference.assetderivativevaluation.models.FiniteDifferenceEquityModel model, double time)
    Compatibility method for equity-only solvers with deterministic discounting.
    static void
    overwriteAsDirichlet(TridiagonalMatrix matrix, double[] rhs, int row, double value)
    Overwrites one matrix row with a Dirichlet condition.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • buildModelCoefficients

      public static ThetaMethod1DAssembly.ModelCoefficients buildModelCoefficients(net.finmath.finitedifference.assetderivativevaluation.models.FiniteDifferenceEquityModel model, double[] xGrid, double time)
      Compatibility method for equity-only solvers with deterministic discounting.

      Evaluates the one-dimensional drift, variance, and scalar short rate on the supplied grid at one time.

      Parameters:
      model - The finite-difference equity model.
      xGrid - The one-dimensional state grid.
      time - The running time.
      Returns:
      The model coefficients.
    • getShortRate

      public static double getShortRate(net.finmath.finitedifference.assetderivativevaluation.models.FiniteDifferenceEquityModel model, double time)
      Compatibility method for equity-only solvers with deterministic discounting.

      Computes the continuously compounded short rate implied by the model discount curve.

      Parameters:
      model - The finite-difference equity model.
      time - The running time.
      Returns:
      The short rate.
    • buildThetaLeftHandSide

      public static void buildThetaLeftHandSide(TridiagonalMatrix lhs, double[] xGrid, double[] drift, double[] variance, double shortRate, double deltaTau, double theta)
      Compatibility overload for deterministic-rate solvers.

      Builds the left-hand side matrix for the theta step using a scalar short rate.

      Parameters:
      lhs - The tridiagonal matrix to overwrite.
      xGrid - The one-dimensional state grid.
      drift - The drift values on the grid.
      variance - The variance values on the grid.
      shortRate - The scalar short rate.
      deltaTau - The time step size.
      theta - The theta parameter.
    • buildThetaLeftHandSide

      public static void buildThetaLeftHandSide(TridiagonalMatrix lhs, double[] xGrid, double[] drift, double[] variance, double[] localDiscountRate, double deltaTau, double theta)
      Builds the left-hand side matrix for the theta step:

      I - theta * dt * L(t_{m+1}).

      Parameters:
      lhs - The tridiagonal matrix to overwrite.
      xGrid - The one-dimensional state grid.
      drift - The drift values on the grid.
      variance - The variance values on the grid.
      localDiscountRate - The local reaction / discount coefficients on the grid.
      deltaTau - The time step size.
      theta - The theta parameter.
    • buildThetaRightHandSide

      public static void buildThetaRightHandSide(TridiagonalMatrix rhsOperator, double[] xGrid, double[] drift, double[] variance, double shortRate, double deltaTau, double theta)
      Compatibility overload for deterministic-rate solvers.

      Builds the right-hand side operator for the theta step using a scalar short rate.

      Parameters:
      rhsOperator - The tridiagonal matrix to overwrite.
      xGrid - The one-dimensional state grid.
      drift - The drift values on the grid.
      variance - The variance values on the grid.
      shortRate - The scalar short rate.
      deltaTau - The time step size.
      theta - The theta parameter.
    • buildThetaRightHandSide

      public static void buildThetaRightHandSide(TridiagonalMatrix rhsOperator, double[] xGrid, double[] drift, double[] variance, double[] localDiscountRate, double deltaTau, double theta)
      Builds the right-hand side operator for the theta step:

      I + (1-theta) * dt * L(t_m).

      Parameters:
      rhsOperator - The tridiagonal matrix to overwrite.
      xGrid - The one-dimensional state grid.
      drift - The drift values on the grid.
      variance - The variance values on the grid.
      localDiscountRate - The local reaction / discount coefficients on the grid.
      deltaTau - The time step size.
      theta - The theta parameter.
    • apply

      public static double[] apply(TridiagonalMatrix matrix, double[] vector)
      Applies a tridiagonal operator to a vector.
      Parameters:
      matrix - The tridiagonal matrix.
      vector - The vector.
      Returns:
      The product matrix * vector.
    • overwriteAsDirichlet

      public static void overwriteAsDirichlet(TridiagonalMatrix matrix, double[] rhs, int row, double value)
      Overwrites one matrix row with a Dirichlet condition.
      Parameters:
      matrix - The matrix.
      rhs - The right-hand side vector.
      row - The row to overwrite.
      value - The prescribed value.