Struct MonotonicLogMixedLinearCubic
QuantLib's preset log-mixed-linear-cubic factory: the spline approximation of the logarithms, monotonic, with second-derivative boundary conditions of 0.
public readonly struct MonotonicLogMixedLinearCubic : 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 MonotonicLogMixedLinearCubic(), an unassigned field or array element) is
refused by every member and by the conversion with InvalidOperationException.
Constructors
MonotonicLogMixedLinearCubic(int, MixedInterpolationBehavior)
Initializes a new instance of the MonotonicLogMixedLinearCubic struct.
public MonotonicLogMixedLinearCubic(int n, MixedInterpolationBehavior behavior = MixedInterpolationBehavior.ShareRanges)
Parameters
nintThe index of the switch point, one of the points.
behaviorMixedInterpolationBehaviorWhether the two interpolations share the points' range or split it.
Exceptions
- ArgumentOutOfRangeException
nis negative, orbehaviorisn'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
pointsintThe 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
xReadOnlySpan<double>The x values, which must be sorted.
yReadOnlySpan<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(MonotonicLogMixedLinearCubic)
The LogMixedLinearCubic the preset is.
public static implicit operator LogMixedLinearCubic(MonotonicLogMixedLinearCubic preset)
Parameters
presetMonotonicLogMixedLinearCubicThe preset.
Returns
- LogMixedLinearCubic
A log-mixed-linear-cubic factory with the preset's switch point and behavior, the spline approximation, 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
RequiredPoints
Gets the fewest points the interpolation takes: 3, as LogMixedLinearCubic's.
static int RequiredPoints { get; }