FunctionPolynomialLeastSquareFitpublic class Polynomial extends java.lang.Object implements Function
| Modifier and Type | Field | Description |
|---|---|---|
protected double[] |
coefficients |
Polynomial coefficients.
|
| Constructor | Description |
|---|---|
Polynomial(double[] coef) |
Constructs a polynomial with the given coefficients.
|
Polynomial(java.lang.String[] coef) |
Constructs a polynomial with the given coefficients.
|
| Modifier and Type | Method | Description |
|---|---|---|
Polynomial |
add(double r) |
|
Polynomial |
add(Polynomial p) |
Adds the given polynomial to this polynomial.
|
double |
coefficient(int n) |
Gets the coefficient value at 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) |
Multiplies this polynomial by a constant.
|
Polynomial |
multiply(Polynomial p) |
Multiplies this polynomial by another polynomial.
|
double[][] |
roots() |
Gets the complex roots of this polynomial.
|
double[] |
rootsReal() |
Gets the real roots of this polynomial.
|
Polynomial |
subtract(double r) |
Subtracts 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
|
public Polynomial(double[] coef)
coef - polynomial coefficients.public Polynomial(java.lang.String[] coef)
coef - polynomial coefficients.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 - Polynomialpublic double coefficient(int n)
n - int the position of the coefficient to be returnedpublic 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 - doublepublic Polynomial divide(Polynomial p)
p - Polynomialpublic Polynomial[] divideWithRemainder(Polynomial p)
p - polynomialpublic Polynomial integral()
public Polynomial integral(double value)
value - double value of the integral at x=0public Polynomial multiply(double r)
r - doublepublic Polynomial multiply(Polynomial p)
p - Polynomialpublic double[][] roots()
public double[] rootsReal()
public Polynomial subtract(double r)
r - the constantpublic Polynomial subtract(Polynomial p)
p - Polynomialpublic java.lang.String toString()
toString in class java.lang.Objectpublic double evaluate(double x)
public double[] valueAndDerivative(double x)
x - double value at which the polynomial is evaluated