Class CubicSplineInterpolator

java.lang.Object
com.irurueta.numerical.interpolation.BaseInterpolator
com.irurueta.numerical.interpolation.CubicSplineInterpolator

public class CubicSplineInterpolator extends BaseInterpolator
Computes cubic spline interpolation. Accuracy of this interpolator worsens as the polynomial degree to interpolate increases. Typically, up to degree 3 results are reasonable.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final int
    Length of x's and y's to take into account.
    private final double[]
     
    private static final double
     
    private static final double
     

    Fields inherited from class com.irurueta.numerical.interpolation.BaseInterpolator

    cor, mm, n, xx, yy
  • Constructor Summary

    Constructors
    Constructor
    Description
    CubicSplineInterpolator(double[] x, double[] y)
    Constructor with x and y vectors and default values for first derivative at the endpoints.
    CubicSplineInterpolator(double[] x, double[] y, double yp1, double ypn)
    Constructor with x and y vectors, and values of the first derivative at the endpoints.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    rawinterp(int jl, double x)
    Actual interpolation method.
    private void
    setY2(double[] xv, double[] yv, double yp1, double ypn)
    This method stores an array y2[0..n-1] with second derivatives of the interpolating function at the tabulated points pointed to by xv, using function values pointed to by yv.

    Methods inherited from class com.irurueta.numerical.interpolation.BaseInterpolator

    hunt, interpolate, locate

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • CubicSplineInterpolator

      public CubicSplineInterpolator(double[] x, double[] y, double yp1, double ypn)
      Constructor with x and y vectors, and values of the first derivative at the endpoints.
      Parameters:
      x - x values to interpolate to. Values in x must be monotonic (either increasing or decreasing)
      y - y values to interpolate to.
      yp1 - 1st derivative at lowest endpoint.
      ypn - 1st derivative at highest endpoint
    • CubicSplineInterpolator

      public CubicSplineInterpolator(double[] x, double[] y)
      Constructor with x and y vectors and default values for first derivative at the endpoints.
      Parameters:
      x - x values to interpolate to. Values in x must be monotonic (either increasing or decreasing)
      y - y values to interpolate to.
  • Method Details

    • rawinterp

      public double rawinterp(int jl, double x) throws InterpolationException
      Actual interpolation method.
      Specified by:
      rawinterp in class BaseInterpolator
      Parameters:
      jl - index where value x to be interpolated in located in the array of xx.
      x - value to obtain interpolation for.
      Returns:
      interpolated value.
      Throws:
      InterpolationException - if interpolation fails.
    • setY2

      private void setY2(double[] xv, double[] yv, double yp1, double ypn)
      This method stores an array y2[0..n-1] with second derivatives of the interpolating function at the tabulated points pointed to by xv, using function values pointed to by yv. If yp1 and/or ypn are equal to 1e99 or larger, the routine is signaled to set the corresponding boundary condition for a natural spline, with zero second derivative on that boundary; otherwise, they are the values of the first derivatives at the endpoints.
      Parameters:
      xv - x values to interpolate to. Values in x must be monotonic (either increasing or decreasing)
      yv - y values to interpolate to.
      yp1 - 1st derivative at lowest endpoint.
      ypn - 1st derivative at highest endpoint