Class CubicSplineInterpolator
java.lang.Object
com.irurueta.numerical.interpolation.BaseInterpolator
com.irurueta.numerical.interpolation.CubicSplineInterpolator
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
FieldsModifier and TypeFieldDescriptionprivate static final intLength of x's and y's to take into account.private final double[]private static final doubleprivate static final double -
Constructor Summary
ConstructorsConstructorDescriptionCubicSplineInterpolator(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 TypeMethodDescriptiondoublerawinterp(int jl, double x) Actual interpolation method.private voidsetY2(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
-
Field Details
-
M
private static final int MLength of x's and y's to take into account.- See Also:
-
YP1
private static final double YP1- See Also:
-
YPN
private static final double YPN- See Also:
-
y2
private final double[] y2
-
-
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
Actual interpolation method.- Specified by:
rawinterpin classBaseInterpolator- 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
-