public class PolynomialFunctionLagrangeForm extends Object implements UnivariateFunction
The approximated function should be smooth enough for Lagrange polynomial to work well. Otherwise, consider using splines instead.
Constructor and Description |
---|
PolynomialFunctionLagrangeForm(double[] xIn,
double[] yIn)
Construct a Lagrange polynomial with the given abscissas and function
values.
|
PolynomialFunctionLagrangeForm(double[] x2,
double[][] ytab2)
Constructs a Lagrange polynomial with the given abscissas and an array of different function
values.
|
Modifier and Type | Method and Description |
---|---|
protected void |
computeCoefficients()
Calculate the coefficients of Lagrange polynomial from the
interpolation data.
|
int |
degree()
Returns the degree of the polynomial.
|
static double |
evaluate(double[] x,
double[] y,
double z)
Evaluate the Lagrange polynomial using
Neville's Algorithm.
|
double[] |
getCoefficients()
Returns a copy of the coefficients array.
|
double[] |
getInterpolatingPoints()
Returns a copy of the interpolating points array.
|
double[][] |
getInterpolatingTabValues()
Returns a copy of the interpolating values matrix.
|
double[] |
getInterpolatingValues()
Returns a copy of the interpolating values array.
|
double |
value(double z)
Calculate the function value at the given point.
|
double |
valueIndex(int index,
double z)
Calculate the function value at the given point.
|
static boolean |
verifyInterpolationArray(double[] x,
double[] y,
boolean abort)
Check that the interpolation arrays are valid.
|
public PolynomialFunctionLagrangeForm(double[] xIn, double[] yIn)
The constructor makes copy of the input arrays and assigns them.
xIn
- interpolating pointsyIn
- function values at interpolating pointsDimensionMismatchException
- if the array lengths are different.NumberIsTooSmallException
- if the number of points is less than 2.NonMonotonicSequenceException
- if two abscissae have the same value.public PolynomialFunctionLagrangeForm(double[] x2, double[][] ytab2)
The constructor makes copy of the input arrays and assigns them.
x2
- interpolating pointsytab2
- function values at interpolating pointsDimensionMismatchException
- if the array lengths are different.NumberIsTooSmallException
- if the number of points is less than 2.NonMonotonicSequenceException
- if two abscissae have the same value.public double value(double z)
value
in interface UnivariateFunction
z
- Point at which the function value is to be computed.DimensionMismatchException
- if x
and y
have
different lengths.NonMonotonicSequenceException
- if x
is not sorted in strictly increasing order.NumberIsTooSmallException
- if the size of x
is less
than 2.public double valueIndex(int index, double z)
index
- : the function to be interpolated, ie btw 0 and yTab.length-1z
- Point at which the function value is to be computed.DimensionMismatchException
- if x
and y
have
different lengths.NonMonotonicSequenceException
- if x
is not sorted in strictly increasing order.NumberIsTooSmallException
- if the size of x
is less
than 2.public int degree()
public double[] getInterpolatingPoints()
Changes made to the returned copy will not affect the polynomial.
public double[] getInterpolatingValues()
Changes made to the returned copy will not affect the polynomial.
public double[][] getInterpolatingTabValues()
Changes made to the returned copy will not affect the polynomial.
public double[] getCoefficients()
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.
public static double evaluate(double[] x, double[] y, double z)
x
- Interpolating points array.y
- Interpolating values array.z
- Point at which the function value is to be computed.DimensionMismatchException
- if x
and y
have
different lengths.NonMonotonicSequenceException
- if x
is not sorted in strictly increasing order.NumberIsTooSmallException
- if the size of x
is less
than 2.protected void computeCoefficients()
public static boolean verifyInterpolationArray(double[] x, double[] y, boolean abort)
x
- Interpolating points array.y
- Interpolating values array.abort
- Whether to throw an exception if x
is not sorted.false
if the x
is not sorted in increasing order, true
otherwise.DimensionMismatchException
- if the array lengths are different.NumberIsTooSmallException
- if the number of points is less than 2.NonMonotonicSequenceException
- if x
is not sorted in strictly increasing order and abort
is true
.evaluate(double[], double[], double)
,
computeCoefficients()
Copyright © 2019 CNES. All Rights Reserved.