Package com.irurueta.numerical.roots
Class LaguerrePolynomialRootsEstimator
java.lang.Object
com.irurueta.numerical.roots.RootEstimator
com.irurueta.numerical.roots.PolynomialRootsEstimator
com.irurueta.numerical.roots.LaguerrePolynomialRootsEstimator
This class estimates the roots of a polynomial of degree n.
p(x) = a0 * x^n + a1 * x^(n - 1) + ... a(n-1) * x + an
then the array of parameters is [an, a(n-1), ... a1, a0]
This class supports polynomials having either real or complex parameters.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final boolean
Constant indicating whether roots will be refined.static final double
Constant considered as machine precision.private static final double[]
Array containing values for Laguerre method.static final double
Constant considered as machine precision for Laguerre method.static final int
Maximum number of iterations.static final int
Minimum allowed length in polynomial parameters.static final int
Constant that affects the number of iterations.static final int
Constant that affects the number of iterations.private boolean
Indicates if roots should be refined.Fields inherited from class com.irurueta.numerical.roots.PolynomialRootsEstimator
polyParams, roots
Fields inherited from class com.irurueta.numerical.roots.RootEstimator
locked
-
Constructor Summary
ConstructorsConstructorDescriptionEmpty constructor.LaguerrePolynomialRootsEstimator
(boolean polishRoots) Constructor.LaguerrePolynomialRootsEstimator
(com.irurueta.algebra.Complex[] polyParams) Constructor.LaguerrePolynomialRootsEstimator
(com.irurueta.algebra.Complex[] polyParams, boolean polishRoots) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns boolean indicating whether roots are refined after an initial estimation.void
estimate()
Estimates the roots of provided polynomial.private void
internalLaguer
(com.irurueta.algebra.Complex[] a, com.irurueta.algebra.Complex x, int[] its) Internal method to compute a root after decomposing and decreasing the degree of the polynomial.protected final void
internalSetPolynomialParameters
(com.irurueta.algebra.Complex[] polyParams) Internal method to set parameters of a polynomial, taking into account that a polynomial of degree n is defined as: p(x) = a0 * x^n + a1 * x^(n - 1) + ...void
setPolishRootsEnabled
(boolean enable) Sets boolean indicating whether roots will be refined after an initial estimation.Methods inherited from class com.irurueta.numerical.roots.PolynomialRootsEstimator
arePolynomialParametersAvailable, areRootsAvailable, getPolynomialParameters, getRoots, isReady, setPolynomialParameters
Methods inherited from class com.irurueta.numerical.roots.RootEstimator
isLocked
-
Field Details
-
MR
public static final int MRConstant that affects the number of iterations.- See Also:
-
MT
public static final int MTConstant that affects the number of iterations.- See Also:
-
MAXIT
public static final int MAXITMaximum number of iterations.- See Also:
-
LAGUER_EPS
public static final double LAGUER_EPSConstant considered as machine precision for Laguerre method.- See Also:
-
EPS
public static final double EPSConstant considered as machine precision.- See Also:
-
DEFAULT_POLISH_ROOTS
public static final boolean DEFAULT_POLISH_ROOTSConstant indicating whether roots will be refined.- See Also:
-
MIN_VALID_POLY_PARAMS_LENGTH
public static final int MIN_VALID_POLY_PARAMS_LENGTHMinimum allowed length in polynomial parameters.- See Also:
-
frac
private static final double[] fracArray containing values for Laguerre method. -
polishRoots
private boolean polishRootsIndicates if roots should be refined.
-
-
Constructor Details
-
LaguerrePolynomialRootsEstimator
public LaguerrePolynomialRootsEstimator(boolean polishRoots) Constructor.- Parameters:
polishRoots
- Boolean to determine whether roots should be refined.
-
LaguerrePolynomialRootsEstimator
public LaguerrePolynomialRootsEstimator()Empty constructor. -
LaguerrePolynomialRootsEstimator
public LaguerrePolynomialRootsEstimator(com.irurueta.algebra.Complex[] polyParams, boolean polishRoots) Constructor.- Parameters:
polyParams
- Array containing polynomial parameters.polishRoots
- Boolean indicating whether roots will be refined.- Throws:
IllegalArgumentException
- Raised if length of provided parameters is not valid. It has to be greater or equal than 2.
-
LaguerrePolynomialRootsEstimator
public LaguerrePolynomialRootsEstimator(com.irurueta.algebra.Complex[] polyParams) Constructor.- Parameters:
polyParams
- Array containing polynomial parameters.- Throws:
IllegalArgumentException
- Raised if length of provided parameters is not valid. It has to be greater or equal than 2.
-
-
Method Details
-
estimate
Estimates the roots of provided polynomial.- Overrides:
estimate
in classRootEstimator
- Throws:
LockedException
- Raised if this instance is locked estimating a root.NotReadyException
- Raised if this instance is not ready because polynomial parameters have not been provided.RootEstimationException
- Raised if roots cannot be estimated for some reason (lack of convergence, etc.).
-
areRootsPolished
public boolean areRootsPolished()Returns boolean indicating whether roots are refined after an initial estimation.- Returns:
- True if roots are refined, false otherwise.
-
setPolishRootsEnabled
Sets boolean indicating whether roots will be refined after an initial estimation.- Parameters:
enable
- True if roots will be refined, false otherwise.- Throws:
LockedException
- Raised if this instance is locked.
-
internalSetPolynomialParameters
protected final void internalSetPolynomialParameters(com.irurueta.algebra.Complex[] polyParams) Internal method to set parameters of a polynomial, taking into account that a polynomial of degree n is defined as: p(x) = a0 * x^n + a1 * x^(n - 1) + ... a(n-1) * x + an then the array of parameters is [an, a(n - 1), ... a1, a0] Polynomial parameters can be either real or complex values This method does not check if this class is locked.- Specified by:
internalSetPolynomialParameters
in classPolynomialRootsEstimator
- Parameters:
polyParams
- Polynomial parameters.- Throws:
IllegalArgumentException
- Raised if the length of the array is not valid.
-
internalLaguer
private void internalLaguer(com.irurueta.algebra.Complex[] a, com.irurueta.algebra.Complex x, int[] its) throws RootEstimationException Internal method to compute a root after decomposing and decreasing the degree of the polynomial.- Parameters:
a
- Remaining polynomial parameters (on 1st iteration, the whole polynomial is provided, on subsequent iterations, the polynomial is deflated and the degree is reduced).x
- Estimated root.its
- number of iterations needed to achieve the estimation.- Throws:
RootEstimationException
- Raised if root couldn't be estimated because of lack of convergence.
-