Class NthOrderDerivativeOp
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
directionintThe direction of the derivative.
orderintThe derivative's order, below
nPoints.nPointsintThe number of points per derivative, from 2 to the direction's size.
mesherFdmMesherThe mesher.
Exceptions
- ArgumentNullException
mesheris null.- ArgumentOutOfRangeException
directionisn't one of the mesher's, ororderis 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
rReadOnlySpan<double>The values, one per point.
resultSpan<double>The result, of
r's length; it mustn't overlapr.
ToMatrix()
The operator as a sparse matrix.
public override SparseMatrix ToMatrix()
Returns
- SparseMatrix
A new matrix.