Class CubicSpline

java.lang.Object
gda.analysis.numerical.interpolation.CubicSpline

public class CubicSpline extends Object
Cubic spline based on Numerical recipies code see. http://www.nrbook.com/b/bookfpdf/f3-3.pdf
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    spline(double[] x, double[] y, int n, double yp1, double ypn, double[] y2)
    Given arrays x[0..n-1] and y[0..n-1] containing a tabulated function, i.e., y_i = f(x_i), with x_0 less than x_1 less than ...
    static double
    splint(double[] xa, double[] ya, double[] y2a, int n, double x)
    Given the arrays xa[0..n-1] and ya[0..n-1], which tabulate a function (with the xa_i¡¯s in order), and given the array y2a[0..n-1], which is the output from spline above, and given a value of x, this routine returns a cubic-spline interpolated value y.

    Methods inherited from class java.lang.Object

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

    • CubicSpline

      public CubicSpline()
  • Method Details

    • spline

      public static void spline(double[] x, double[] y, int n, double yp1, double ypn, double[] y2)
      Given arrays x[0..n-1] and y[0..n-1] containing a tabulated function, i.e., y_i = f(x_i), with x_0 less than x_1 less than ... less than x_n-1, and given values yp_0 and yp_n-1 for the first derivative of the interpolating function at points 0 and n-1, respectively, this routine returns an array y2[0..n-1] that contains the second derivatives of the interpolating function at the tabulated points x_i. If yp_0 and/or yp_n-1 are equal to 1 \times 10^30 or larger, the routine is signaled to set the corresponding boundary condition for a natural spline, with zero second derivative on that boundary.
      Parameters:
      x - x values
      y - y values
      n - array lengths
      yp1 - first derivative at 0
      ypn - first derivative at n-1
      y2 - second derivative of the interpolating function at points x[i]
    • splint

      public static double splint(double[] xa, double[] ya, double[] y2a, int n, double x)
      Given the arrays xa[0..n-1] and ya[0..n-1], which tabulate a function (with the xa_i¡¯s in order), and given the array y2a[0..n-1], which is the output from spline above, and given a value of x, this routine returns a cubic-spline interpolated value y.
      Parameters:
      xa -
      ya -
      y2a -
      n -
      x -
      Returns:
      interpolated value at x