|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.math.analysis.PolynomialFunctionNewtonForm
public class PolynomialFunctionNewtonForm
Implements the representation of a real polynomial function in Newton Form. For reference, see Elementary Numerical Analysis, ISBN 0070124477, chapter 2.
The formula of polynomial in Newton form is p(x) = a[0] + a[1](x-c[0]) + a[2](x-c[0])(x-c[1]) + ... + a[n](x-c[0])(x-c[1])...(x-c[n-1]) Note that the length of a[] is one more than the length of c[]
Field Summary | |
---|---|
private double[] |
a
Members of c[] are called centers of the Newton polynomial. |
private double[] |
c
Members of c[] are called centers of the Newton polynomial. |
private double[] |
coefficients
The coefficients of the polynomial, ordered by degree -- i.e. |
private boolean |
coefficientsComputed
Whether the polynomial coefficients are available. |
(package private) static long |
serialVersionUID
serializable version identifier |
Constructor Summary | |
---|---|
PolynomialFunctionNewtonForm(double[] a,
double[] c)
Construct a Newton polynomial with the given a[] and c[]. |
Method Summary | |
---|---|
protected void |
computeCoefficients()
Calculate the normal polynomial coefficients given the Newton form. |
int |
degree()
Returns the degree of the polynomial. |
static double |
evaluate(double[] a,
double[] c,
double z)
Evaluate the Newton polynomial using nested multiplication. |
double[] |
getCenters()
Returns a copy of the centers array. |
double[] |
getCoefficients()
Returns a copy of the coefficients array. |
double[] |
getNewtonCoefficients()
Returns a copy of coefficients in Newton form formula. |
double |
value(double z)
Calculate the function value at the given point. |
protected static void |
verifyInputArray(double[] a,
double[] c)
Verifies that the input arrays are valid. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static final long serialVersionUID
private double[] coefficients
private double[] a
private double[] c
private boolean coefficientsComputed
Constructor Detail |
---|
PolynomialFunctionNewtonForm(double[] a, double[] c) throws java.lang.IllegalArgumentException
The constructor makes copy of the input arrays and assigns them.
a
- the coefficients in Newton form formulac
- the centers
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[] getNewtonCoefficients()
Changes made to the returned copy will not affect the polynomial.
public double[] getCenters()
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[] a, double[] c, double z) throws FunctionEvaluationException, java.lang.IllegalArgumentException
a
- the coefficients in Newton form formulac
- the centersz
- the point at which the function value is to be computed
FunctionEvaluationException
- if a runtime error occurs
java.lang.IllegalArgumentException
- if inputs are not validprotected void computeCoefficients()
protected static void verifyInputArray(double[] a, double[] c) throws java.lang.IllegalArgumentException
The centers must be distinct for interpolation purposes, but not for general use. Thus it is not verified here.
a
- the coefficients in Newton form formulac
- the centers
java.lang.IllegalArgumentException
- if not validDividedDifferenceInterpolator.computeDividedDifference(double[],
double[])
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |