Class AbstractBoundCurveInterpolator

    • 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 high
        yValues - the y-values of the curve
      • AbstractBoundCurveInterpolator

        protected AbstractBoundCurveInterpolator​(AbstractBoundCurveInterpolator base,
                                                 BoundCurveExtrapolator extrapolatorLeft,
                                                 BoundCurveExtrapolator extrapolatorRight)
        Creates an instance.
        Parameters:
        base - the base interpolator
        extrapolatorLeft - the extrapolator for x-values on the left
        extrapolatorRight - 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 interface BoundCurveInterpolator
        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 for InterpolatorCurveExtrapolator 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 interface BoundCurveInterpolator
        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 interface BoundCurveInterpolator
        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 order
        • xValue is greater or equal to the first element of xValues
        • xValue is less than or equal to the last element of xValues
        The returned value satisfies:
           0 <= value < xValues.length
         

        The x-values must not be NaN.

        Parameters:
        xValue - a value which is less than the last element in xValues
        xValues - an array of values sorted in ascending order
        Returns:
        the index of the last value in xValues which is lower than xValue