Class ZeroPolynomial
- All Implemented Interfaces:
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe iteration did not converge -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleThe smallest relative spacing for doubles. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionComplex[]computeRoots(double[] coef) Computes the roots of the polynomial with real coefficients.Complex[]computeRoots(Complex[] coef) Computes the roots of the polynomial with Complex coefficients.doublegetRadius(int index) Returns an a-posteriori absolute error bound on the root.getRoot(int index) Returns a zero of the polynomial.Complex[]getRoots()Returns the zeros of the polynomial.booleangetStatus(int index) Returns the error status of a root.voidsetMaxIterations(int maxIterations) Sets the maximum number of iterations allowed.
-
Field Details
-
EPSILON_SMALL
public static final double EPSILON_SMALLThe smallest relative spacing for doubles.- See Also:
-
-
Constructor Details
-
ZeroPolynomial
public ZeroPolynomial()Creates an instance of the solver.
-
-
Method Details
-
setMaxIterations
public void setMaxIterations(int maxIterations) Sets the maximum number of iterations allowed. The default value is 30.- Parameters:
maxIterations- anintwhich specifies the maximum number of iterations allowed- Throws:
IllegalArgumentException- is thrown ifmaxIterationsis less than or equal to zero.
-
getRoot
Returns a zero of the polynomial.- Parameters:
index- anintwhich specifies the (0-based) index of the root to be returned- Returns:
- a
Complexwhich represents the index-th root of the polynomial
-
getRoots
Returns the zeros of the polynomial.- Returns:
- a
Complexarray containing the roots of the polynomial
-
getRadius
public double getRadius(int index) Returns an a-posteriori absolute error bound on the root.- Parameters:
index- anintspecifying the (0-based) index of the root whose error bound is to be returned- Returns:
- a
doublerepresenting 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.
-
getStatus
public boolean getStatus(int index) Returns the error status of a root.- Parameters:
index- anintrepresenting the (0-based) index of the root whose error status is to be returned- Returns:
- a
booleanrepresenting 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.
-
computeRoots
Computes the roots of the polynomial with real coefficients.$$p(x) = {\rm coef}[n] \times x^n + {\rm coef}[n-1] \times x^{n-1} + \ldots + {\rm coef}[0]$$
- Parameters:
coef- adoublearray containing the polynomial coefficients- Returns:
- a
Complexarray containing the roots of the polynomial - Throws:
ZeroPolynomial.DidNotConvergeException
-
computeRoots
Computes the roots of the polynomial with Complex coefficients.$$p(x) = {\rm coef}[n] \times x^n + {\rm coef}[n-1] \times x^{n-1} + \ldots + {\rm coef}[0]$$
- Parameters:
coef- aComplexarray containing the polynomial coefficients.- Returns:
- a
Complexarray containing the roots of the polynomial. - Throws:
ZeroPolynomial.DidNotConvergeException
-