Class AbstractBoundCurveInterpolator
- java.lang.Object
-
- com.opengamma.strata.market.curve.interpolator.AbstractBoundCurveInterpolator
-
- All Implemented Interfaces:
BoundCurveInterpolator
public abstract class AbstractBoundCurveInterpolator extends Object implements BoundCurveInterpolator
Abstract interpolator implementation.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractBoundCurveInterpolator(DoubleArray xValues, DoubleArray yValues)
Creates an instance.protected
AbstractBoundCurveInterpolator(AbstractBoundCurveInterpolator base, BoundCurveExtrapolator extrapolatorLeft, BoundCurveExtrapolator extrapolatorRight)
Creates an instance.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract double
doFirstDerivative(double xValue)
Method for subclasses to calculate the first derivative.protected abstract double
doInterpolate(double xValue)
Method for subclasses to calculate the interpolated value.protected double
doInterpolateFromExtrapolator(double xValue)
Method forInterpolatorCurveExtrapolator
to calculate the interpolated value.protected abstract DoubleArray
doParameterSensitivity(double xValue)
Method for subclasses to calculate parameter sensitivity.double
firstDerivative(double xValue)
Computes the first derivative of the y-value for the specified x-value.double
interpolate(double xValue)
Computes the y-value for the specified x-value by interpolation.protected static int
lowerBoundIndex(double xValue, double[] xValues)
Returns the index of the last value in the input array which is lower than the specified value.DoubleArray
parameterSensitivity(double xValue)
Computes the sensitivity of the y-value with respect to the curve parameters.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.opengamma.strata.market.curve.interpolator.BoundCurveInterpolator
bind
-
-
-
-
Constructor Detail
-
AbstractBoundCurveInterpolator
protected AbstractBoundCurveInterpolator(DoubleArray xValues, DoubleArray yValues)
Creates an instance.- Parameters:
xValues
- the x-values of the curve, must be sorted from low to highyValues
- the y-values of the curve
-
AbstractBoundCurveInterpolator
protected AbstractBoundCurveInterpolator(AbstractBoundCurveInterpolator base, BoundCurveExtrapolator extrapolatorLeft, BoundCurveExtrapolator extrapolatorRight)
Creates an instance.- Parameters:
base
- the base interpolatorextrapolatorLeft
- the extrapolator for x-values on the leftextrapolatorRight
- the extrapolator for x-values on the right
-
-
Method Detail
-
interpolate
public final double interpolate(double xValue)
Description copied from interface:BoundCurveInterpolator
Computes the y-value for the specified x-value by interpolation.- Specified by:
interpolate
in interfaceBoundCurveInterpolator
- Parameters:
xValue
- the x-value to find the y-value for- Returns:
- the value at the x-value
-
doInterpolate
protected abstract double doInterpolate(double xValue)
Method for subclasses to calculate the interpolated value.Callers can assume that
xValue
is less than the x-value of the last node.- Parameters:
xValue
- the x-value- Returns:
- the interpolated y-value
-
doInterpolateFromExtrapolator
protected double doInterpolateFromExtrapolator(double xValue)
Method forInterpolatorCurveExtrapolator
to calculate the interpolated value.This is separated from
doInterpolate(double)
to allow the check for x-values beyond the last node to be treated separately.- Parameters:
xValue
- the x-value- Returns:
- the interpolated y-value
-
firstDerivative
public final double firstDerivative(double xValue)
Description copied from interface:BoundCurveInterpolator
Computes the first derivative of the y-value for the specified x-value.The first derivative is
dy/dx
.- Specified by:
firstDerivative
in interfaceBoundCurveInterpolator
- Parameters:
xValue
- the x-value at which the derivative is taken- Returns:
- the first derivative
-
doFirstDerivative
protected abstract double doFirstDerivative(double xValue)
Method for subclasses to calculate the first derivative.- Parameters:
xValue
- the x-value- Returns:
- the first derivative
-
parameterSensitivity
public final DoubleArray parameterSensitivity(double xValue)
Description copied from interface:BoundCurveInterpolator
Computes the sensitivity of the y-value with respect to the curve parameters.This returns an array with one element for each parameter of the curve. The array contains the sensitivity of the y-value at the specified x-value to each parameter.
- Specified by:
parameterSensitivity
in interfaceBoundCurveInterpolator
- Parameters:
xValue
- the x-value at which the parameter sensitivity is computed- Returns:
- the sensitivity
-
doParameterSensitivity
protected abstract DoubleArray doParameterSensitivity(double xValue)
Method for subclasses to calculate parameter sensitivity.- Parameters:
xValue
- the x-value- Returns:
- the parameter sensitivity
-
lowerBoundIndex
protected static int lowerBoundIndex(double xValue, double[] xValues)
Returns the index of the last value in the input array which is lower than the specified value.The following conditions must be true for this method to work correctly:
xValues
is sorted in ascending orderxValue
is greater or equal to the first element ofxValues
xValue
is less than or equal to the last element ofxValues
0 <= value < xValues.length
The x-values must not be NaN.
- Parameters:
xValue
- a value which is less than the last element inxValues
xValues
- an array of values sorted in ascending order- Returns:
- the index of the last value in
xValues
which is lower thanxValue
-
-