public class HermiteInterpolator extends Object implements UnivariateDifferentiableVectorFunction
The interpolation polynomials match all sample points, including both values and provided derivatives. There is one polynomial for each component of the values vector. All polynomials have the same degree. The degree of the polynomials depends on the number of points and number of derivatives at each point. For example the interpolation polynomials for n sample points without any derivatives all have degree n-1. The interpolation polynomials for n sample points with the two extreme points having value and first derivative and the remaining points having value only all have degree n+1. The interpolation polynomial for n sample points with value, first and second derivative for all points all have degree 3n-1.
Constructor and Description |
---|
HermiteInterpolator()
Create an empty interpolator.
|
Modifier and Type | Method and Description |
---|---|
void |
addSamplePoint(double x,
double[]... value)
Add a sample point.
|
double[][] |
derivatives(double x,
int order)
Interpolate value and first derivatives at a specified abscissa.
|
PolynomialFunction[] |
getPolynomials()
Compute the interpolation polynomials.
|
double[] |
value(double x)
Interpolate value at a specified abscissa.
|
<T extends Derivative<T>> |
value(T x)
Compute the value for the function.
|
public void addSamplePoint(double x, double[]... value) throws MathIllegalArgumentException, MathRuntimeException
This method must be called once for each sample point. It is allowed to mix some calls with values only with calls with values and first derivatives.
The point abscissae for all calls must be different.
x
- abscissa of the sample pointvalue
- value and derivatives of the sample point
(if only one row is passed, it is the value, if two rows are
passed the first one is the value and the second the derivative
and so on)MathIllegalArgumentException
- if the abscissa difference between added point
and a previous point is zero (i.e. the two points are at same abscissa)MathRuntimeException
- if the number of derivatives is larger
than 20, which prevents computation of a factorialpublic PolynomialFunction[] getPolynomials() throws MathIllegalArgumentException
MathIllegalArgumentException
- if sample is emptypublic double[] value(double x) throws MathIllegalArgumentException
Calling this method is equivalent to call the value
methods of all polynomials returned by getPolynomials
,
except it does not build the intermediate polynomials, so this method is faster and
numerically more stable.
value
in interface UnivariateVectorFunction
x
- interpolation abscissaMathIllegalArgumentException
- if sample is emptypublic <T extends Derivative<T>> T[] value(T x) throws MathIllegalArgumentException
value
in interface UnivariateDifferentiableVectorFunction
T
- the type of the field elementsx
- the point for which the function value should be computedMathIllegalArgumentException
- if x
does not
satisfy the function's constraints (argument out of bound, or unsupported
derivative order for example)public double[][] derivatives(double x, int order) throws MathIllegalArgumentException, NullArgumentException
x
- interpolation abscissaorder
- maximum derivation orderMathIllegalArgumentException
- if sample is emptyNullArgumentException
- if x is nullCopyright © 2016-2021 CS GROUP. All rights reserved.