Struct LogMixedLinearCubic
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
nintThe index of the switch point, one of the points.
behaviorMixedInterpolationBehaviorWhether the two interpolations share the points' range or split it.
daCubicInterpolationDerivativeApproxThe cubic part's first-derivative approximation of the logarithms.
monotonicboolWhether to apply Hyman's monotonicity filter to the cubic part.
leftConditionCubicInterpolationBoundaryConditionThe cubic part's left boundary condition, for the spline approximation.
leftConditionValuedouble?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).
rightConditionCubicInterpolationBoundaryConditionThe cubic part's right boundary condition, for the spline approximation.
rightConditionValuedoubleThe right condition's value, where it takes one.
Exceptions
- ArgumentOutOfRangeException
nis 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
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 a LogMixedLinearCubicInterpolation over the given points, which it copies, with this factory's parameters.
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 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
RequiredPoints
Gets the fewest points the interpolation takes: 3.
static int RequiredPoints { get; }