Top Description Fields Constructors Methods
org.apache.commons.math3.analysis.interpolation

public Class HermiteInterpolator

extends Object
implements UnivariateDifferentiableVectorFunction
Class Inheritance
All Implemented Interfaces
org.apache.commons.math3.analysis.differentiation.UnivariateDifferentiableVectorFunction, org.apache.commons.math3.analysis.UnivariateVectorFunction
Imports
java.util.ArrayList, .Arrays, .List, org.apache.commons.math3.analysis.differentiation.DerivativeStructure, .UnivariateDifferentiableVectorFunction, org.apache.commons.math3.analysis.polynomials.PolynomialFunction, org.apache.commons.math3.exception.MathArithmeticException, .NoDataException, .ZeroException, org.apache.commons.math3.exception.util.LocalizedFormats, org.apache.commons.math3.util.CombinatoricsUtils

Polynomial interpolator using both sample values and sample derivatives.

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.

Since
3.1

Field Summary

Modifier and TypeField and Description
private final List<Double>
abscissae

Sample abscissae.

private final List<double[]>
bottomDiagonal

Bottom diagonal of the divided differences array.

private final List<double[]>
topDiagonal

Top diagonal of the divided differences array.

Constructor Summary

AccessConstructor and Description
public
HermiteInterpolator()

Create an empty interpolator.

Method Summary

Modifier and TypeMethod and Description
public void
addSamplePoint(final double
abscissa of the sample point
x
,
final double[]...
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)
value
)

Add a sample point.

private void
checkInterpolation()

Check interpolation can be performed.

public PolynomialFunction[]

Returns:

interpolation polynomials array
getPolynomials
()
Deprecated as a consequence of PolynomialFunction being deprecated.

Compute the interpolation polynomials.

private PolynomialFunction

Returns:

polynomial
polynomial
(double...
polynomials coefficients
c
)
Deprecated as a consequence of PolynomialFunction being deprecated.

Create a polynomial from its coefficients.

public double[]

Returns:

interpolated value
value
(double
interpolation abscissa
x
)

Implements org.apache.commons.math3.analysis.UnivariateVectorFunction.value.

Interpolate value at a specified abscissa.

public DerivativeStructure[]

Returns:

interpolated value
value
(final DerivativeStructure
interpolation abscissa
x
)

Implements org.apache.commons.math3.analysis.differentiation.UnivariateDifferentiableVectorFunction.value.

Interpolate value at a specified abscissa.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

abscissaeback to summary
private final List<Double> abscissae

Sample abscissae.

bottomDiagonalback to summary
private final List<double[]> bottomDiagonal

Bottom diagonal of the divided differences array.

topDiagonalback to summary
private final List<double[]> topDiagonal

Top diagonal of the divided differences array.

Constructor Detail

HermiteInterpolatorback to summary
public HermiteInterpolator()

Create an empty interpolator.

Method Detail

addSamplePointback to summary
public void addSamplePoint(final double x, final double[]... value) throws ZeroException, MathArithmeticException

Add a sample point.

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.

Parameters
x:double

abscissa of the sample point

value:double[][]

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)

Exceptions
ZeroException:
if the abscissa difference between added point and a previous point is zero (i.e. the two points are at same abscissa)
MathArithmeticException:
if the number of derivatives is larger than 20, which prevents computation of a factorial
checkInterpolationback to summary
private void checkInterpolation() throws NoDataException

Check interpolation can be performed.

Exceptions
NoDataException:
if interpolation cannot be performed because sample is empty
getPolynomialsback to summary
public PolynomialFunction[] getPolynomials() throws NoDataException

Deprecated

as a consequence of PolynomialFunction being deprecated. See corresponding docs for further information.

Compute the interpolation polynomials.

Returns:PolynomialFunction[]

interpolation polynomials array

Exceptions
NoDataException:
if sample is empty
polynomialback to summary
private PolynomialFunction polynomial(double... c)

Deprecated

as a consequence of PolynomialFunction being deprecated. See corresponding docs for further information.

Create a polynomial from its coefficients.

Parameters
c:double[]

polynomials coefficients

Returns:PolynomialFunction

polynomial

valueback to summary
public double[] value(double x) throws NoDataException

Implements org.apache.commons.math3.analysis.UnivariateVectorFunction.value.

Interpolate value at a specified abscissa.

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.

Parameters
x:double

interpolation abscissa

Returns:double[]

interpolated value

Exceptions
NoDataException:
if sample is empty
valueback to summary
public DerivativeStructure[] value(final DerivativeStructure x) throws NoDataException

Implements org.apache.commons.math3.analysis.differentiation.UnivariateDifferentiableVectorFunction.value.

Interpolate value at a specified abscissa.

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.

Parameters
x:DerivativeStructure

interpolation abscissa

Returns:DerivativeStructure[]

interpolated value

Exceptions
NoDataException:
if sample is empty