|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectmath.approximations.Polynomial
public class Polynomial
Polynomial implements a mathematical polynomial: c[0] + c[1] * x + c[2] * x^2 + .... This class is based on code published in Object-Oriented Implementation of Numerical Methods by Didier H. Besset. The code has been adapted to the OSP framework by Wolfgang Christian.
| Constructor Summary | |
|---|---|
Polynomial(double[] coef)
Constructs a polynomial with the given coefficients. |
|
Polynomial(java.lang.String[] coef)
Constructs a polynomial with the given coefficients. |
|
| Method Summary | |
|---|---|
Polynomial |
add(double r)
|
Polynomial |
add(Polynomial p)
Adds the given polynomial to this polynomial. |
double |
coefficient(int n)
Gets the coefficient value affineTransform the desired position |
Polynomial |
deflate(double r)
Deflates the polynomial by removing the root. |
int |
degree()
Gets the degree of this polynomial function. |
Polynomial |
derivative()
Gets the derivative of this polynomial. |
Polynomial |
divide(double r)
Divides this polynomial by a constant. |
Polynomial |
divide(Polynomial p)
Divides this polynomial by another polynomial. |
Polynomial[] |
divideWithRemainder(Polynomial p)
Divides this polynomial by another polynomial. |
static double |
evalPolynomial(double x,
double[] coeff)
Evaluates a polynomial using the given coefficients. |
double |
evaluate(double x)
Evaluates the polynomial for the specified variable value. |
double[] |
getCoefficients()
Gets a clone of the polynomial coefficients c: c[0] + c[1] * x + c[2] * x^2 + .... |
Polynomial |
integral()
Integrates this polynomial. |
Polynomial |
integral(double value)
Integrates this polynomial having the specified value for x = 0. |
Polynomial |
multiply(double r)
Multipiels this polynomial by a constant. |
Polynomial |
multiply(Polynomial p)
Multiplies this polynomial by another polynomial. |
double[] |
roots()
Gets the roots of this polynomial. |
double[] |
roots(double desiredPrecision)
Gets the roots of this polynomial. |
Polynomial |
subtract(double r)
Substracts a constant from this polynomial. |
Polynomial |
subtract(Polynomial p)
Subtracts another polynomial from this polynomial. |
java.lang.String |
toString()
Converts this polynomial to a String. |
double[] |
valueAndDerivative(double x)
Returns the value and the derivative of this polynomial for the specified variable value in an array of two elements |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Polynomial(double[] coef)
coef - polynomial coefficients.public Polynomial(java.lang.String[] coef)
coef - polynomial coefficients.| Method Detail |
|---|
public double[] getCoefficients()
public static double evalPolynomial(double x,
double[] coeff)
x - coeff - the polynomial coefficients.public Polynomial add(double r)
r - double number added to the polynomial.
public Polynomial add(Polynomial p)
p - Polynomial
public double coefficient(int n)
n - int the position of the coefficient to be returned
public Polynomial deflate(double r)
r - double a root of the polynomial (no check made).
public int degree()
public Polynomial derivative()
public Polynomial divide(double r)
r - double
public Polynomial divide(Polynomial p)
p - Polynomial
public Polynomial[] divideWithRemainder(Polynomial p)
public Polynomial integral()
public Polynomial integral(double value)
value - double value of the integral affineTransform x=0
public Polynomial multiply(double r)
r - double
public Polynomial multiply(Polynomial p)
p - Polynomial
public double[] roots()
public double[] roots(double desiredPrecision)
desiredPrecision - double
public Polynomial subtract(double r)
public Polynomial subtract(Polynomial p)
p - Polynomial
public java.lang.String toString()
toString in class java.lang.Objectpublic double evaluate(double x)
evaluate in interface Functionx - double value affineTransform which the polynomial is evaluated
public double[] valueAndDerivative(double x)
x - double value affineTransform which the polynomial is evaluated
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||