Class Interpolation.CubicSpline

  • All Implemented Interfaces:
    Fn
    Enclosing class:
    Interpolation

    public static class Interpolation.CubicSpline
    extends Interpolation.InterpolatedFunction
    A CubicSpline interpolator passes through each point in its data set, connecting the points with cubic spline curves. The array of x values used to define the curve must be ordered and strictly increasing. That is, for i in 0..x.length-2, x[i] < x[i+1].
    • Field Summary

      • Fields inherited from interface ca.cgjennings.math.Fn

        IDENTITY
    • Constructor Summary

      Constructors 
      Constructor Description
      CubicSpline​(double[] x, double[] y)
      Creates a cubic spline that passes through the points (x[0],y[0]), (x[1],y[1]), ..., (x[x.length-1],y[y.length-1).
      CubicSpline​(double[] x, double[] y, double yp0, double ypN)
      Creates a cubic spline that passes through the points (x[0],y[0]), (x[1],y[1]), ..., (x[x.length-1],y[y.length-1).
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double f​(double xValue)
      Returns the y-value of the interpolation function given an x-value.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CubicSpline

        public CubicSpline​(double[] x,
                           double[] y)
        Creates a cubic spline that passes through the points (x[0],y[0]), (x[1],y[1]), ..., (x[x.length-1],y[y.length-1). Default derivatives will be computed for the end points of the spline.
        Parameters:
        x - an array of x-values for the points
        y - an array of y-values for the points
        Throws:
        java.lang.NullPointerException - if either array is null
        java.lang.IllegalArgumentException - if the data point criteria are not met
      • CubicSpline

        public CubicSpline​(double[] x,
                           double[] y,
                           double yp0,
                           double ypN)
        Creates a cubic spline that passes through the points (x[0],y[0]), (x[1],y[1]), ..., (x[x.length-1],y[y.length-1). This constructor specifies the derivatives at the lower (yp0) and upper (ypN) boundaries of the function.
        Parameters:
        x - an array of x-values for the points
        y - an array of y-values for the points
        yp0 - derivative at the lower boundary, or Double.NaN to let the interpolator choose
        ypN - derivative at the upper boundary, or Double.NaN to let the interpolator choose
        Throws:
        java.lang.NullPointerException - if either array is null
        java.lang.IllegalArgumentException - if the data point criteria are not met
    • Method Detail

      • f

        public double f​(double xValue)
        Description copied from class: Interpolation.InterpolatedFunction
        Returns the y-value of the interpolation function given an x-value.
        Specified by:
        f in interface Fn
        Specified by:
        f in class Interpolation.InterpolatedFunction
        Parameters:
        xValue - the value to evaluate the curve function at
        Returns:
        f(x), where f is a function for the interpolating curve