Class FieldPolynomialFunctionLagrangeForm<T extends CalculusFieldElement<T>>
java.lang.Object
org.hipparchus.analysis.polynomials.FieldPolynomialFunctionLagrangeForm<T>
- Type Parameters:
T
- type of the field elements
- All Implemented Interfaces:
CalculusFieldUnivariateFunction<T>
public class FieldPolynomialFunctionLagrangeForm<T extends CalculusFieldElement<T>>
extends Object
implements CalculusFieldUnivariateFunction<T>
Implements the representation of a real polynomial function in
Lagrange Form. For reference, see Introduction to Numerical
Analysis, ISBN 038795452X, chapter 2.
The approximated function should be smooth enough for Lagrange polynomial to work well. Otherwise, consider using splines instead.
- Since:
- 4.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionFieldPolynomialFunctionLagrangeForm
(T[] x, T[] y) Construct a Lagrange polynomial with the given abscissas and function values. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Calculate the coefficients of Lagrange polynomial from the interpolation data.int
degree()
Returns the degree of the polynomial.T[]
Returns a copy of the coefficients array.T[]
Returns a copy of the interpolating points array.T[]
Returns a copy of the interpolating values array.Calculate the function value at the given point.
-
Constructor Details
-
FieldPolynomialFunctionLagrangeForm
Construct a Lagrange polynomial with the given abscissas and function values. The order of interpolating points is important.The constructor makes copy of the input arrays and assigns them.
- Parameters:
x
- interpolating pointsy
- function values at interpolating points- Throws:
MathIllegalArgumentException
- if the array lengths are different.MathIllegalArgumentException
- if the number of points is less than 2.MathIllegalArgumentException
- if two abscissae have the same value.MathIllegalArgumentException
- if the abscissae are not sorted.
-
-
Method Details
-
value
Calculate the function value at the given point.- Specified by:
value
in interfaceCalculusFieldUnivariateFunction<T extends CalculusFieldElement<T>>
- Parameters:
z
- Point at which the function value is to be computed.- Returns:
- the function value.
- Throws:
MathIllegalArgumentException
- ifx
andy
have different lengths.MathIllegalArgumentException
- ifx
is not sorted in strictly increasing order.MathIllegalArgumentException
- if the size ofx
is less than 2.
-
degree
public int degree()Returns the degree of the polynomial.- Returns:
- the degree of the polynomial
-
getInterpolatingPoints
Returns a copy of the interpolating points array.Changes made to the returned copy will not affect the polynomial.
- Returns:
- a fresh copy of the interpolating points array
-
getInterpolatingValues
Returns a copy of the interpolating values array.Changes made to the returned copy will not affect the polynomial.
- Returns:
- a fresh copy of the interpolating values array
-
getCoefficients
Returns a copy of the coefficients array.Changes made to the returned copy will not affect the polynomial.
Note that coefficients computation can be ill-conditioned. Use with caution and only when it is necessary.
- Returns:
- a fresh copy of the coefficients array
-
computeCoefficients
protected void computeCoefficients()Calculate the coefficients of Lagrange polynomial from the interpolation data. It takes O(n^2) time. Note that this computation can be ill-conditioned: Use with caution and only when it is necessary.
-