Table of Contents

Class BicubicSpline

Namespace
NanoQL.Numerics
Assembly
NanoQL.dll

Bicubic-spline interpolation between discrete points.

public sealed class BicubicSpline : Interpolation2D
Inheritance
BicubicSpline
Inherited Members
Extension Methods

Remarks

The matrix holds a row per y value and a column per x value: the value at (xi, yj) is zData[j, i]. Each row is a natural cubic spline in x (Spline, not monotonic, a second derivative of 0 at both ends), built with the interpolation; a value is the natural cubic spline in y through the rows' values at x, built at each call, each spline extrapolating outside its range. The x and y values must be sorted.

The five derivatives follow QuantLib's: DerivativeX(double, double) and SecondDerivativeX(double, double) differentiate the spline in x through the values at the x nodes, DerivativeY(double, double) and SecondDerivativeY(double, double) the spline in y of the value, and DerivativeXY(double, double) the spline in x of DerivativeY(double, double) at the nodes. As in QuantLib, they skip the range check Evaluate(double, double, bool) makes, and the spline they differentiate refuses a point outside its own range, whatever the extrapolation flag.

A matrix larger than the grid is read in its first rows and columns, as QuantLib reads it; a smaller one, which QuantLib reads past its end, is refused. It copies its inputs, as every Interpolation2D does, so a change of the caller's matrix is a new interpolation, where QuantLib's reads the matrix by reference until update().

Constructors

BicubicSpline(ReadOnlySpan<double>, ReadOnlySpan<double>, Matrix)

Initializes a new instance of the BicubicSpline class.

public BicubicSpline(ReadOnlySpan<double> x, ReadOnlySpan<double> y, Matrix zData)

Parameters

x ReadOnlySpan<double>

The x values, which must be sorted; at least 2.

y ReadOnlySpan<double>

The y values, which must be sorted; at least 2.

zData Matrix

The function values, a row per y value and a column per x value.

Exceptions

ArgumentNullException

zData is null.

ArgumentException

There are fewer than 2 x or y values, or the matrix has fewer rows than y values or fewer columns than x values.

Methods

DerivativeX(double, double)

The first derivative in x at (x, y).

public double DerivativeX(double x, double y)

Parameters

x double

The x coordinate.

y double

The y coordinate.

Returns

double

The derivative.

Exceptions

NanoQLException

x is outside the x range.

DerivativeXY(double, double)

The mixed derivative in x and y at (x, y).

public double DerivativeXY(double x, double y)

Parameters

x double

The x coordinate.

y double

The y coordinate.

Returns

double

The derivative.

Exceptions

NanoQLException

x or y is outside its range.

DerivativeY(double, double)

The first derivative in y at (x, y).

public double DerivativeY(double x, double y)

Parameters

x double

The x coordinate.

y double

The y coordinate.

Returns

double

The derivative.

Exceptions

NanoQLException

y is outside the y range.

SecondDerivativeX(double, double)

The second derivative in x at (x, y).

public double SecondDerivativeX(double x, double y)

Parameters

x double

The x coordinate.

y double

The y coordinate.

Returns

double

The derivative.

Exceptions

NanoQLException

x is outside the x range.

SecondDerivativeY(double, double)

The second derivative in y at (x, y).

public double SecondDerivativeY(double x, double y)

Parameters

x double

The x coordinate.

y double

The y coordinate.

Returns

double

The derivative.

Exceptions

NanoQLException

y is outside the y range.

ValueCore(double, double)

The interpolated value at a point, after the range check.

protected override double ValueCore(double x, double y)

Parameters

x double

The x coordinate.

y double

The y coordinate.

Returns

double

The value.