|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.math.analysis.polynomials.PolynomialFunctionLagrangeForm
public class PolynomialFunctionLagrangeForm
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.
Constructor Summary | |
---|---|
PolynomialFunctionLagrangeForm(double[] x,
double[] y)
Construct a Lagrange polynomial with the given abscissas and function values. |
Method Summary | |
---|---|
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[] |
getInterpolatingValues()
Returns a copy of the interpolating values array. |
double |
value(double z)
Calculate the function value at the given point. |
static void |
verifyInterpolationArray(double[] x,
double[] y)
Verifies that the interpolation arrays are valid. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PolynomialFunctionLagrangeForm(double[] x, double[] y) throws java.lang.IllegalArgumentException
The constructor makes copy of the input arrays and assigns them.
x
- interpolating pointsy
- function values at interpolating points
java.lang.IllegalArgumentException
- if input arrays are not validMethod Detail |
---|
public double value(double z) throws FunctionEvaluationException
value
in interface UnivariateRealFunction
z
- the point at which the function value is to be computed
FunctionEvaluationException
- if a runtime error occursUnivariateRealFunction.value(double)
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[] getCoefficients()
Changes made to the returned copy will not affect the polynomial.
public static double evaluate(double[] x, double[] y, double z) throws DuplicateSampleAbscissaException, java.lang.IllegalArgumentException
This function is made public static so that users can call it directly without instantiating PolynomialFunctionLagrangeForm object.
x
- the interpolating points arrayy
- the interpolating values arrayz
- the point at which the function value is to be computed
DuplicateSampleAbscissaException
- if the sample has duplicate abscissas
java.lang.IllegalArgumentException
- if inputs are not validprotected void computeCoefficients() throws java.lang.ArithmeticException
Note this computation can be ill-conditioned. Use with caution and only when it is necessary.
java.lang.ArithmeticException
- if any abscissas coincidepublic static void verifyInterpolationArray(double[] x, double[] y) throws java.lang.IllegalArgumentException
The interpolating points must be distinct. However it is not verified here, it is checked in evaluate() and computeCoefficients().
x
- the interpolating points arrayy
- the interpolating values array
java.lang.IllegalArgumentException
- if not validevaluate(double[], double[], double)
,
computeCoefficients()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |