Class FdmSquareRootFwdOp
The square-root process's linear operator for the Fokker-Planck forward equation: the density of the variance (or of a transformation of it) in one direction of a mesher, its drift κ(θ − v) and diffusion ½σ²v, with zero-flux boundaries.
[WorkingType]
public sealed class FdmSquareRootFwdOp : FdmLinearOpComposite
- Inheritance
-
FdmSquareRootFwdOp
- Inherited Members
Remarks
A working type: built at construction, its time-independent operator applied and solved into the caller's spans, so a step allocates nothing. The direction's grid needs at least two points, where QuantLib reads past a shorter one.
Constructors
FdmSquareRootFwdOp(FdmMesher, double, double, double, int, FdmSquareRootFwdOpTransformationType)
Initializes a new instance of the FdmSquareRootFwdOp class.
public FdmSquareRootFwdOp(FdmMesher mesher, double kappa, double theta, double sigma, int direction, FdmSquareRootFwdOpTransformationType transform = FdmSquareRootFwdOpTransformationType.Plain)
Parameters
mesherFdmMesherThe mesher.
kappadoubleThe mean-reversion speed κ.
thetadoubleThe mean-reversion level θ.
sigmadoubleThe volatility σ.
directionintThe direction of the variance.
transformFdmSquareRootFwdOpTransformationTypeThe variable the density is written in.
Exceptions
- ArgumentNullException
mesheris null.- ArgumentOutOfRangeException
The direction isn't one of the layout's, or
transformisn't a member of its type.- ArgumentException
The direction's grid has fewer than two points.
Properties
Size
Gets the number of directions.
public override int Size { get; }
Property Value
Methods
Apply(ReadOnlySpan<double>, Span<double>)
Applies the operator to r, writing the result into the caller's span.
public override void Apply(ReadOnlySpan<double> r, Span<double> result)
Parameters
rReadOnlySpan<double>The values, one per point.
resultSpan<double>The result, of
r's length; it mustn't overlapr.
ApplyDirection(int, ReadOnlySpan<double>, Span<double>)
Applies the operator's part in one direction, writing the result into the caller's span.
public override void ApplyDirection(int direction, ReadOnlySpan<double> r, Span<double> result)
Parameters
directionintThe direction.
rReadOnlySpan<double>The values, one per point.
resultSpan<double>The result, of
r's length.
ApplyMixed(ReadOnlySpan<double>, Span<double>)
Applies the operator's mixed part, writing the result into the caller's span.
public override void ApplyMixed(ReadOnlySpan<double> r, Span<double> result)
Parameters
rReadOnlySpan<double>The values, one per point.
resultSpan<double>The result, of
r's length.
LowerBoundaryFactor(FdmSquareRootFwdOpTransformationType)
The zero-flux factor at the lower boundary in a transformation.
public double LowerBoundaryFactor(FdmSquareRootFwdOpTransformationType type = FdmSquareRootFwdOpTransformationType.Plain)
Parameters
typeFdmSquareRootFwdOpTransformationTypeThe transformation.
Returns
- double
The factor.
Exceptions
- ArgumentOutOfRangeException
typeisn't a member of its type, with QuantLib's message.
Preconditioner(ReadOnlySpan<double>, double, Span<double>)
Applies the preconditioner of (1 + s·A), writing the result into the caller's
span.
public override void Preconditioner(ReadOnlySpan<double> r, double s, Span<double> result)
Parameters
rReadOnlySpan<double>The values, one per point.
sdoubleThe scale of the operator.
resultSpan<double>The result, of
r's length.
SetTime(double, double)
Sets the operator for the interval [t1, t2].
public override void SetTime(double t1, double t2)
Parameters
Remarks
The operator doesn't depend on time.
SolveSplitting(int, ReadOnlySpan<double>, double, Span<double>)
Solves (1 + s·Adirection) x = r for x, writing it into the
caller's span.
public override void SolveSplitting(int direction, ReadOnlySpan<double> r, double s, Span<double> result)
Parameters
directionintThe direction.
rReadOnlySpan<double>The right-hand side, one value per point.
sdoubleThe scale of the direction's operator.
resultSpan<double>The solution, of
r's length.
ToMatrixDecomp()
The operator as sparse matrices, one per part.
public override ImmutableArray<SparseMatrix> ToMatrixDecomp()
Returns
- ImmutableArray<SparseMatrix>
The matrices.
Exceptions
- NanoQLException
The operator has no sparse representation.
UpperBoundaryFactor(FdmSquareRootFwdOpTransformationType)
The zero-flux factor at the upper boundary in a transformation.
public double UpperBoundaryFactor(FdmSquareRootFwdOpTransformationType type = FdmSquareRootFwdOpTransformationType.Plain)
Parameters
typeFdmSquareRootFwdOpTransformationTypeThe transformation.
Returns
- double
The factor.
Exceptions
- ArgumentOutOfRangeException
typeisn't a member of its type, with QuantLib's message.
V(int)
The grid's i-th value, from 1, the grid's points; 0 and the size plus one are the points beyond its ends (QuantLib's ghost points).
public double V(int i)
Parameters
iintThe index, from 0 to the grid's size plus one.
Returns
- double
The value.
Exceptions
- ArgumentOutOfRangeException
iis outside [0, size + 1], with QuantLib's message.