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 protectedAbstractBoundCurveInterpolator(DoubleArray xValues, DoubleArray yValues)Creates an instance.protectedAbstractBoundCurveInterpolator(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 doubledoFirstDerivative(double xValue)Method for subclasses to calculate the first derivative.protected abstract doubledoInterpolate(double xValue)Method for subclasses to calculate the interpolated value.protected doubledoInterpolateFromExtrapolator(double xValue)Method forInterpolatorCurveExtrapolatorto calculate the interpolated value.protected abstract DoubleArraydoParameterSensitivity(double xValue)Method for subclasses to calculate parameter sensitivity.doublefirstDerivative(double xValue)Computes the first derivative of the y-value for the specified x-value.doubleinterpolate(double xValue)Computes the y-value for the specified x-value by interpolation.protected static intlowerBoundIndex(double xValue, double[] xValues)Returns the index of the last value in the input array which is lower than the specified value.DoubleArrayparameterSensitivity(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:BoundCurveInterpolatorComputes the y-value for the specified x-value by interpolation.- Specified by:
interpolatein 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
xValueis 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 forInterpolatorCurveExtrapolatorto 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:BoundCurveInterpolatorComputes the first derivative of the y-value for the specified x-value.The first derivative is
dy/dx.- Specified by:
firstDerivativein 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:BoundCurveInterpolatorComputes 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:
parameterSensitivityin 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:
xValuesis sorted in ascending orderxValueis greater or equal to the first element ofxValuesxValueis 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 inxValuesxValues- an array of values sorted in ascending order- Returns:
- the index of the last value in
xValueswhich is lower thanxValue
-
-