Table of Contents

Class NthOrderDerivativeOp

Namespace
NanoQL.Methods
Assembly
NanoQL.dll

The n-th order derivative in one direction as a sparse linear operator: at each point, Fornberg's weights on the given number of the direction's grid points around it, shifted inward at the grid's edges.

[WorkingType]
public sealed class NthOrderDerivativeOp : FdmLinearOp
Inheritance
NthOrderDerivativeOp
Inherited Members

Remarks

A working type of the finite-difference framework: Apply(ReadOnlySpan<double>, Span<double>) writes into the caller's span, and ToMatrix() returns a copy of the operator's matrix. The direction's locations are deduplicated and sorted, as QuantLib's set of them, so the weights' offsets are distinct.

Constructors

NthOrderDerivativeOp(int, int, int, FdmMesher)

Initializes a new instance of the NthOrderDerivativeOp class.

public NthOrderDerivativeOp(int direction, int order, int nPoints, FdmMesher mesher)

Parameters

direction int

The direction of the derivative.

order int

The derivative's order, below nPoints.

nPoints int

The number of points per derivative, from 2 to the direction's size.

mesher FdmMesher

The mesher.

Exceptions

ArgumentNullException

mesher is null.

ArgumentOutOfRangeException

direction isn't one of the mesher's, or order is negative.

ArgumentException

The direction's locations repeat, the number of points is inconsistent, or it isn't above the order.

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.

ToMatrix()

The operator as a sparse matrix.

public override SparseMatrix ToMatrix()

Returns

SparseMatrix

A new matrix.