Class SplineInterpolator
- All Implemented Interfaces:
FieldUnivariateInterpolator
,UnivariateInterpolator
The interpolate(double[], double[])
method returns a PolynomialSplineFunction
consisting 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]
where
i
is the index of the subinterval. See PolynomialSplineFunction
for 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
-
Method Summary
Modifier and TypeMethodDescriptioninterpolate
(double[] x, double[] y) Computes an interpolating function for the data set.<T extends CalculusFieldElement<T>>
FieldPolynomialSplineFunction<T>interpolate
(T[] x, T[] y) Computes an interpolating function for the data set.
-
Constructor Details
-
SplineInterpolator
public SplineInterpolator()Empty constructor.This constructor is not strictly necessary, but it prevents spurious javadoc warnings with JDK 18 and later.
- Since:
- 3.0
-
-
Method Details
-
interpolate
public PolynomialSplineFunction interpolate(double[] x, double[] y) throws MathIllegalArgumentException Computes an interpolating function for the data set.- Specified by:
interpolate
in interfaceUnivariateInterpolator
- Parameters:
x
- the arguments for the interpolation pointsy
- the values for the interpolation points- Returns:
- a function which interpolates the data set
- Throws:
MathIllegalArgumentException
- ifx
andy
have different sizes.MathIllegalArgumentException
- ifx
is not sorted in strict increasing order.MathIllegalArgumentException
- if the size ofx
is smaller than 3.
-
interpolate
public <T extends CalculusFieldElement<T>> FieldPolynomialSplineFunction<T> interpolate(T[] x, T[] y) throws MathIllegalArgumentException Computes an interpolating function for the data set.- Specified by:
interpolate
in interfaceFieldUnivariateInterpolator
- Type Parameters:
T
- the type of the field elements- Parameters:
x
- the arguments for the interpolation pointsy
- the values for the interpolation points- Returns:
- a function which interpolates the data set
- Throws:
MathIllegalArgumentException
- ifx
andy
have different sizes.MathIllegalArgumentException
- ifx
is not sorted in strict increasing order.MathIllegalArgumentException
- if the size ofx
is smaller than 3.- Since:
- 1.5
-