public class ZeroPolynomial extends Object implements Serializable, Cloneable
All the software contained in this library is protected by copyright Permission to use, copy, modify, and distribute this software for any purpose without fee is hereby granted, provided that this entire notice is included in all copies of any software which is or includes a copy or modification of this software and in all copies of the supporting documentation for such software.
THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED WARRANTY. IN NO EVENT, NEITHER THE AUTHORS, NOR THE PUBLISHER, NOR ANY MEMBER OF THE EDITORIAL BOARD OF THE JOURNAL "NUMERICAL ALGORITHMS", NOR ITS EDITOR-IN-CHIEF, BE LIABLE FOR ANY ERROR IN THE SOFTWARE, ANY MISUSE OF IT OR ANY DAMAGE ARISING OUT OF ITS USE. THE ENTIRE RISK OF USING THE SOFTWARE LIES WITH THE PARTY DOING SO. ANY USE OF THE SOFTWARE CONSTITUTES ACCEPTANCE OF THE TERMS OF THE ABOVE STATEMENT.
| Modifier and Type | Class and Description |
|---|---|
static class |
ZeroPolynomial.DidNotConvergeException
The iteration did not converge
|
| Modifier and Type | Field and Description |
|---|---|
static double |
EPSILON_SMALL
The smallest relative spacing for doubles.
|
| Constructor and Description |
|---|
ZeroPolynomial()
Creates an instance of the solver.
|
| Modifier and Type | Method and Description |
|---|---|
Complex[] |
computeRoots(Complex[] coef)
Computes the roots of the polynomial with Complex coefficients.
|
Complex[] |
computeRoots(double[] coef)
Computes the roots of the polynomial with real coefficients.
|
double |
getRadius(int index)
Returns an a-posteriori absolute error bound on the root.
|
Complex |
getRoot(int index)
Returns a zero of the polynomial.
|
Complex[] |
getRoots()
Returns the zeros of the polynomial.
|
boolean |
getStatus(int index)
Returns the error status of a root.
|
void |
setMaxIterations(int maxIterations)
Sets the maximum number of iterations allowed.
|
public static final double EPSILON_SMALL
public void setMaxIterations(int maxIterations)
maxIterations - an int which specifies the
maximum number of iterations allowedIllegalArgumentException - is thrown if maxIterations is
less than or equal to zero.public Complex getRoot(int index)
index - an int which specifies the
(0-based) index of the root to be returnedComplex which represents the
index-th root of the polynomialpublic Complex[] getRoots()
Complex array containing the roots
of the polynomialpublic double getRadius(int index)
index - an int specifying the (0-based) index
of the root whose error bound is to be returneddouble representing the error bound on the
index-th root. NaN is returned if the corresponding root
cannot be represented as floating point due to overflow or
underflow or if the roots have not yet been computed.public boolean getStatus(int index)
index - an int representing the (0-based) index
of the root whose error status is to be returnedboolean representing the error status on
the index-th root. It is false if the approximation of
the index-th root has been carried out successfully,
for example, the computed approximation can be viewed
as the exact root of a slightly perturbed polynomial. It
is true if more iterations are needed for the index-th
root.public Complex[] computeRoots(double[] coef) throws ZeroPolynomial.DidNotConvergeException
$$p(x) = {\rm coef}[n] \times x^n + {\rm coef}[n-1] \times x^{n-1} + \ldots + {\rm coef}[0]$$
coef - a double array containing the
polynomial coefficientsComplex array containing the
roots of the polynomialZeroPolynomial.DidNotConvergeExceptionpublic Complex[] computeRoots(Complex[] coef) throws ZeroPolynomial.DidNotConvergeException
$$p(x) = {\rm coef}[n] \times x^n + {\rm coef}[n-1] \times x^{n-1} + \ldots + {\rm coef}[0]$$
coef - a Complex array containing the
polynomial coefficients.Complex array containing the
roots of the polynomial.ZeroPolynomial.DidNotConvergeExceptionCopyright © 2020 Rogue Wave Software. All rights reserved.