Class ClampedSplineInterpolator
- java.lang.Object
-
- org.apache.commons.math4.legacy.analysis.interpolation.SplineInterpolator
-
- org.apache.commons.math4.legacy.analysis.interpolation.ClampedSplineInterpolator
-
- All Implemented Interfaces:
UnivariateInterpolator
public class ClampedSplineInterpolator extends SplineInterpolator
Computes a clamped cubic spline interpolation for the data set.The
interpolate(double[], double[], double, double)
method returns aPolynomialSplineFunction
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]
wherei
is the index of the subinterval. SeePolynomialSplineFunction
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 clamped boundary condition, i.e., the PolynomialSplineFunction takes "a specific direction" at both
its start point and its end point by providing the desired first derivative values (slopes) as function parameters to
interpolate(double[], double[], double, double)
.
The clamped cubic spline interpolation algorithm implemented is as described in R.L. Burden, J.D. Faires, Numerical Analysis, 9th Ed., 2010, Cengage Learning, ISBN 0-538-73351-9, pp 153-156.
-
-
Constructor Summary
Constructors Constructor Description ClampedSplineInterpolator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PolynomialSplineFunction
interpolate(double[] x, double[] y, double fpo, double fpn)
Computes an interpolating function for the data set.-
Methods inherited from class org.apache.commons.math4.legacy.analysis.interpolation.SplineInterpolator
interpolate
-
-
-
-
Constructor Detail
-
ClampedSplineInterpolator
public ClampedSplineInterpolator()
-
-
Method Detail
-
interpolate
public PolynomialSplineFunction interpolate(double[] x, double[] y, double fpo, double fpn) throws DimensionMismatchException, NumberIsTooSmallException, NonMonotonicSequenceException
Computes an interpolating function for the data set.- Parameters:
x
- the arguments for the interpolation pointsy
- the values for the interpolation pointsfpo
- first derivative at the starting point of the returned spline function (starting slope), satisfying clamped boundary condition S′(x0) = f′(x0)fpn
- first derivative at the ending point of the returned spline function (ending slope), satisfying clamped boundary condition S′(xn) = f′(xn)- Returns:
- a function which interpolates the data set
- Throws:
DimensionMismatchException
- ifx
andy
have different sizes.NumberIsTooSmallException
- if the size ofx < 3
.NonMonotonicSequenceException
- ifx
is not sorted in strict increasing order.
-
-