Table of Contents

Struct KrugerLogMixedLinearCubic

Namespace
NanoQL.Numerics
Assembly
NanoQL.dll

QuantLib's preset log-mixed-linear-cubic factory: Kruger's approximation of the logarithms, not monotonic, with second-derivative boundary conditions of 0.

public readonly struct KrugerLogMixedLinearCubic : IInterpolator
Implements
Inherited Members

Remarks

A configuration struct holding QuantLib's two parameters, the switch point and the behavior, so that it can be a type argument where QuantLib names it as one. QuantLib derives it from LogMixedLinearCubic: here it converts to the LogMixedLinearCubic it is. QuantLib's has no default constructor, since its switch point has no default, so its zero value (default, new KrugerLogMixedLinearCubic(), an unassigned field or array element) is refused by every member and by the conversion with InvalidOperationException.

Constructors

KrugerLogMixedLinearCubic(int, MixedInterpolationBehavior)

Initializes a new instance of the KrugerLogMixedLinearCubic struct.

public KrugerLogMixedLinearCubic(int n, MixedInterpolationBehavior behavior = MixedInterpolationBehavior.ShareRanges)

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.

Exceptions

ArgumentOutOfRangeException

n is negative, or behavior isn't a member of its enum.

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 the preset's LogMixedLinearCubicInterpolation over the given points, which it copies.

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 switch point isn't one of the points, a part has too few points, or a y value isn't positive.

Operators

implicit operator LogMixedLinearCubic(KrugerLogMixedLinearCubic)

The LogMixedLinearCubic the preset is.

public static implicit operator LogMixedLinearCubic(KrugerLogMixedLinearCubic preset)

Parameters

preset KrugerLogMixedLinearCubic

The preset.

Returns

LogMixedLinearCubic

A log-mixed-linear-cubic factory with the preset's switch point and behavior, Kruger's approximation, not monotonic, and second-derivative conditions of 0.

Exceptions

InvalidOperationException

The preset is its zero value, which QuantLib can't construct.

Explicit Interface Implementations

Global

Gets a value indicating whether the interpolation is global: true, as LogMixedLinearCubic's.

static bool Global { get; }

Returns

bool

RequiredPoints

Gets the fewest points the interpolation takes: 3, as LogMixedLinearCubic's.

static int RequiredPoints { get; }

Returns

int