Table of Contents

Struct LogMixedLinearCubic

Namespace
NanoQL.Numerics
Assembly
NanoQL.dll

The log-mixed-linear-cubic interpolation factory and traits.

public readonly struct LogMixedLinearCubic : IInterpolator
Implements
Inherited Members

Remarks

A configuration struct holding QuantLib's eight parameters, which it doesn't expose, as QuantLib doesn't. QuantLib's LogMixedLinearCubic has no default constructor, since its switch point, behavior and derivative approximation have no defaults, so its zero value (default, new LogMixedLinearCubic(), an unassigned field or array element) is refused by every member with InvalidOperationException, as ImmutableArray<T>'s default is.

QuantLib's presets MonotonicLogMixedLinearCubic and KrugerLogMixedLinearCubic are structs of their own, each converting to the LogMixedLinearCubic it is.

Constructors

LogMixedLinearCubic(int, MixedInterpolationBehavior, CubicInterpolationDerivativeApprox, bool, CubicInterpolationBoundaryCondition, double?, CubicInterpolationBoundaryCondition, double)

Initializes a new instance of the LogMixedLinearCubic struct.

public LogMixedLinearCubic(int n, MixedInterpolationBehavior behavior, CubicInterpolationDerivativeApprox da, bool monotonic = true, CubicInterpolationBoundaryCondition leftCondition = CubicInterpolationBoundaryCondition.SecondDerivative, double? leftConditionValue = 0, CubicInterpolationBoundaryCondition rightCondition = CubicInterpolationBoundaryCondition.SecondDerivative, double rightConditionValue = 0)

Parameters

n int

The index of the switch point, one of the points.

behavior MixedInterpolationBehavior

Whether the two interpolations share the points' range or split it.

da CubicInterpolationDerivativeApprox

The cubic part's first-derivative approximation of the logarithms.

monotonic bool

Whether to apply Hyman's monotonicity filter to the cubic part.

leftCondition CubicInterpolationBoundaryCondition

The cubic part's left boundary condition, for the spline approximation.

leftConditionValue double?

The left condition's value, where it takes one; null with a first-derivative condition to match the linear part's derivative at the switch point (MixedLinearCubicInterpolation).

rightCondition CubicInterpolationBoundaryCondition

The cubic part's right boundary condition, for the spline approximation.

rightConditionValue double

The right condition's value, where it takes one.

Exceptions

ArgumentOutOfRangeException

n is negative, or an enum argument isn't a member of its type.

Methods

CheckPoints(int)

Runs the checks QuantLib's interpolation makes when it is built over a number of points, before it reads their values: the fewest points its implementation takes, and the counts its configuration needs.

public void CheckPoints(int points)

Parameters

points int

The number of points.

Remarks

The bootstraps read it on their first pass: QuantLib builds a curve's interpolation over its first nodes before their values are solved (interpolateWithoutUpdate), and takes linear interpolation where a global interpolation refuses to be built over that many points (iterativebootstrap.hpp:295-310). Interpolate(ReadOnlySpan<double>, ReadOnlySpan<double>) runs every check, these and the ones on the values alike. The default refuses none, so a factory of one's own keeps compiling; a factory overrides it with its construction checks, so that a curve on it takes the fallback where QuantLib's would.

Exceptions

ArgumentException

The interpolation can't be built over that many points.

NanoQLException

The interpolation's configuration can't be built over that many points.

InvalidOperationException

This is the zero value, which QuantLib can't construct.

Interpolate(ReadOnlySpan<double>, ReadOnlySpan<double>)

Builds a LogMixedLinearCubicInterpolation over the given points, which it copies, with this factory's parameters.

public Interpolation Interpolate(ReadOnlySpan<double> x, ReadOnlySpan<double> y)

Parameters

x ReadOnlySpan<double>

The x values, which must be sorted.

y ReadOnlySpan<double>

The y values, one per x value, each positive.

Returns

Interpolation

The interpolation.

Exceptions

InvalidOperationException

This is the zero value, which QuantLib can't construct.

ArgumentException

The sizes differ, there are fewer than 3 points, the derivatives are matched with ShareRanges, the switch point isn't one of the points, a part has too few points, or a y value isn't positive.

NanoQLException

The cubic part's scheme or a condition isn't implemented, or its spline's system has a zero pivot.

Explicit Interface Implementations

Global

Gets a value indicating whether the interpolation is global: true.

static bool Global { get; }

Returns

bool

RequiredPoints

Gets the fewest points the interpolation takes: 3.

static int RequiredPoints { get; }

Returns

int