Package ca.cgjennings.math
Class Interpolation.CubicSpline
- java.lang.Object
-
- ca.cgjennings.math.Interpolation.InterpolatedFunction
-
- ca.cgjennings.math.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, fori
in0..x.length-2
,x[i] < x[i+1]
.
-
-
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 ca.cgjennings.math.Interpolation.InterpolatedFunction
checkPoints
-
-
-
-
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 pointsy
- an array of y-values for the points- Throws:
java.lang.NullPointerException
- if either array isnull
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 pointsy
- an array of y-values for the pointsyp0
- derivative at the lower boundary, orDouble.NaN
to let the interpolator chooseypN
- derivative at the upper boundary, orDouble.NaN
to let the interpolator choose- Throws:
java.lang.NullPointerException
- if either array isnull
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 interfaceFn
- Specified by:
f
in classInterpolation.InterpolatedFunction
- Parameters:
xValue
- the value to evaluate the curve function at- Returns:
- f(x), where f is a function for the interpolating curve
-
-