Class FdmLocalVolFwdOp
The local-volatility forward (Fokker-Planck) operator in the logarithm of the underlying, in one direction: the density's drift −(r − q − σ²/2) and half the local variance at each point, each on the columns of the first and second derivatives, over a time step.
[WorkingType]
public sealed class FdmLocalVolFwdOp : FdmLinearOpComposite
- Inheritance
-
FdmLocalVolFwdOp
- Inherited Members
Remarks
A working type: SetTime(double, double) rewrites the operator's bands in place, through buffers it holds, by QuantLib's arithmetic in QuantLib's order, so a time step allocates nothing. The spot is QuantLib's constructor's argument, which QuantLib's operator doesn't read.
Its times run on the risk-free curve's day counter from the earliest reference date of its three structures, as Clock(GeneralizedBlackScholesProcess, FdmQuantoHelper?)'s, and each structure is read at the instants the step's times denote, on its own clock, where QuantLib reads them at the risk-free curve's times (the mismatched-dates class); structures that share the risk-free curve's times keep QuantLib's bits. A documented divergence.
Constructors
FdmLocalVolFwdOp(FdmMesher, double, YieldTermStructure, YieldTermStructure, LocalVolTermStructure, int)
Initializes a new instance of the FdmLocalVolFwdOp class.
public FdmLocalVolFwdOp(FdmMesher mesher, double spot, YieldTermStructure rTS, YieldTermStructure qTS, LocalVolTermStructure localVol, int direction = 0)
Parameters
mesherFdmMesherThe mesher.
spotdoubleThe spot, which the operator doesn't read, as QuantLib's.
rTSYieldTermStructureThe risk-free curve.
qTSYieldTermStructureThe dividend curve.
localVolLocalVolTermStructureThe local volatility.
directionintThe direction of the underlying.
Exceptions
- ArgumentNullException
An argument is null.
- ArgumentOutOfRangeException
The direction isn't one of the layout's.
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.
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
Exceptions
- ArgumentException
t2is beforet1, or a curve can't be read.- NanoQLException
A curve or the local volatility can't be read.
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.