public class AkimaSplineInterpolator extends java.lang.Object implements UnivariateInterpolator
This implementation is based on the Akima implementation in the CubicSpline class in the Math.NET Numerics library. The method referenced is CubicSpline.InterpolateAkimaSorted
The interpolate
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 Akima algorithm requires that n >= 5
.
Modifier and Type | Field and Description |
---|---|
private static int |
MINIMUM_NUMBER_POINTS
The minimum number of points that are needed to compute the function.
|
Constructor and Description |
---|
AkimaSplineInterpolator() |
Modifier and Type | Method and Description |
---|---|
private double |
differentiateThreePoint(double[] xvals,
double[] yvals,
int indexOfDifferentiation,
int indexOfFirstSample,
int indexOfSecondsample,
int indexOfThirdSample)
Three point differentiation helper, modeled off of the same method in the
Math.NET CubicSpline class.
|
PolynomialSplineFunction |
interpolate(double[] xvals,
double[] yvals)
Computes an interpolating function for the data set.
|
private PolynomialSplineFunction |
interpolateHermiteSorted(double[] xvals,
double[] yvals,
double[] firstDerivatives)
Creates a Hermite cubic spline interpolation from the set of (x,y) value
pairs and their derivatives.
|
private static final int MINIMUM_NUMBER_POINTS
public PolynomialSplineFunction interpolate(double[] xvals, double[] yvals) throws DimensionMismatchException, NumberIsTooSmallException, NonMonotonicSequenceException
interpolate
in interface UnivariateInterpolator
xvals
- the arguments for the interpolation pointsyvals
- the values for the interpolation pointsDimensionMismatchException
- if xvals
and yvals
have
different sizes.NonMonotonicSequenceException
- if xvals
is not sorted in
strict increasing order.NumberIsTooSmallException
- if the size of xvals
is smaller
than 5.private double differentiateThreePoint(double[] xvals, double[] yvals, int indexOfDifferentiation, int indexOfFirstSample, int indexOfSecondsample, int indexOfThirdSample)
xvals
- x values to calculate the numerical derivative withyvals
- y values to calculate the numerical derivative withindexOfDifferentiation
- index of the elemnt we are calculating the derivative aroundindexOfFirstSample
- index of the first element to sample for the three point methodindexOfSecondsample
- index of the second element to sample for the three point methodindexOfThirdSample
- index of the third element to sample for the three point methodprivate PolynomialSplineFunction interpolateHermiteSorted(double[] xvals, double[] yvals, double[] firstDerivatives)
xvals
- x values for interpolationyvals
- y values for interpolationfirstDerivatives
- first derivative values of the function