Table of Contents

Class FdmSquareRootFwdOp

Namespace
NanoQL.Methods
Assembly
NanoQL.dll

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

mesher FdmMesher

The mesher.

kappa double

The mean-reversion speed κ.

theta double

The mean-reversion level θ.

sigma double

The volatility σ.

direction int

The direction of the variance.

transform FdmSquareRootFwdOpTransformationType

The variable the density is written in.

Exceptions

ArgumentNullException

mesher is null.

ArgumentOutOfRangeException

The direction isn't one of the layout's, or transform isn'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

int

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

r ReadOnlySpan<double>

The values, one per point.

result Span<double>

The result, of r's length; it mustn't overlap r.

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

direction int

The direction.

r ReadOnlySpan<double>

The values, one per point.

result Span<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

r ReadOnlySpan<double>

The values, one per point.

result Span<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

type FdmSquareRootFwdOpTransformationType

The transformation.

Returns

double

The factor.

Exceptions

ArgumentOutOfRangeException

type isn'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

r ReadOnlySpan<double>

The values, one per point.

s double

The scale of the operator.

result Span<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

t1 double

The start time.

t2 double

The end time, not before t1.

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

direction int

The direction.

r ReadOnlySpan<double>

The right-hand side, one value per point.

s double

The scale of the direction's operator.

result Span<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

type FdmSquareRootFwdOpTransformationType

The transformation.

Returns

double

The factor.

Exceptions

ArgumentOutOfRangeException

type isn'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

i int

The index, from 0 to the grid's size plus one.

Returns

double

The value.

Exceptions

ArgumentOutOfRangeException

i is outside [0, size + 1], with QuantLib's message.