Class SplineInterpolator
- java.lang.Object
-
- org.apache.commons.math4.legacy.analysis.interpolation.SplineInterpolator
-
- All Implemented Interfaces:
UnivariateInterpolator
- Direct Known Subclasses:
ClampedSplineInterpolator
public class SplineInterpolator extends Object implements UnivariateInterpolator
Computes a natural (also known as "free", "unclamped") cubic spline interpolation for the data set.The
interpolate(double[], double[])method returns aPolynomialSplineFunctionconsisting of n cubic polynomials, defined over the subintervals determined by the x values,x[0] < x[i] ... < x[n].The x values are referred to as "knot points."The value of the PolynomialSplineFunction at a point x that is greater than or equal to the smallest knot point and strictly less than the largest knot point is computed by finding the subinterval to which x belongs and computing the value of the corresponding polynomial at
x - x[i]whereiis the index of the subinterval. SeePolynomialSplineFunctionfor more details.The interpolating polynomials satisfy:
- The value of the PolynomialSplineFunction at each of the input x values equals the corresponding y value.
- Adjacent polynomials are equal through two derivatives at the knot points (i.e., adjacent polynomials "match up" at the knot points, as do their first and second derivatives).
The cubic spline interpolation algorithm implemented is as described in R.L. Burden, J.D. Faires, Numerical Analysis, 4th Ed., 1989, PWS-Kent, ISBN 0-53491-585-X, pp 126-131.
-
-
Constructor Summary
Constructors Constructor Description SplineInterpolator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PolynomialSplineFunctioninterpolate(double[] x, double[] y)Computes an interpolating function for the data set.
-
-
-
Constructor Detail
-
SplineInterpolator
public SplineInterpolator()
-
-
Method Detail
-
interpolate
public PolynomialSplineFunction interpolate(double[] x, double[] y)
Computes an interpolating function for the data set.- Specified by:
interpolatein interfaceUnivariateInterpolator- Parameters:
x- the arguments for the interpolation pointsy- the values for the interpolation points- Returns:
- a function which interpolates the data set
- Throws:
DimensionMismatchException- ifxandyhave different sizes.NumberIsTooSmallException- if the size ofx < 3.NonMonotonicSequenceException- ifxis not sorted in strict increasing order.
-
-