![]() |
Eigen-Contrib
5.0.1-dev+master
|
#include <contrib/Eigen/src/Polynomials/PolynomialSolver.h>
A polynomial solver.
Computes the complex roots of a real polynomial.
| Scalar_ | the scalar type, i.e., the type of the polynomial coefficients |
| Deg_ | the degree of the polynomial, can be a compile time value or Dynamic. Notice that the number of polynomial coefficients is Deg_+1. |
This class implements a polynomial solver and provides convenient methods such as
WARNING: this polynomial solver is experimental, part of the contrib Eigen modules.
By default the roots are the eigenvalues of the balanced companion matrix of the polynomial, which are, as a set, the roots of one polynomial near the given one, also for multiple and clustered roots, followed by a clean-up that returns the roots of a real polynomial as real numbers or exact conjugate pairs. A root of multiplicity \( m \) can only be located to about \( \varepsilon^{1/m} \).
With the optional argument refine = true of the constructor and of compute(), Ehrlich-Aberth iterations on the polynomial itself first refine the eigenvalues, targeting a residual within the rounding error of evaluation, with a finite sweep limit and an initial-estimate fallback for iterates whose residual increased, or that would leave Cauchy's bound on the root moduli. Coincident estimates keep their eigenvalues. Refined roots are individually more accurate for well-separated roots, but for multiple or clustered roots they are no longer jointly the roots of one nearby polynomial, which is why the refinement is off by default.
Inheritance diagram for Eigen::PolynomialSolver< Scalar_, Deg_ >:Public Member Functions | |
| template<typename OtherPolynomial> | |
| void | compute (const OtherPolynomial &poly, bool refine=false) |
Public Member Functions inherited from Eigen::PolynomialSolverBase< Scalar_, Deg_ > | |
| const RealScalar & | absGreatestRealRoot (bool &hasArealRoot, const RealScalar &absImaginaryThreshold=NumTraits< Scalar >::dummy_precision()) const |
| const RealScalar & | absSmallestRealRoot (bool &hasArealRoot, const RealScalar &absImaginaryThreshold=NumTraits< Scalar >::dummy_precision()) const |
| const RealScalar & | greatestRealRoot (bool &hasArealRoot, const RealScalar &absImaginaryThreshold=NumTraits< Scalar >::dummy_precision()) const |
| const RootType & | greatestRoot () const |
| template<typename Stl_back_insertion_sequence> | |
| void | realRoots (Stl_back_insertion_sequence &bi_seq, const RealScalar &absImaginaryThreshold=NumTraits< Scalar >::dummy_precision()) const |
| const RootsType & | roots () const |
| const RealScalar & | smallestRealRoot (bool &hasArealRoot, const RealScalar &absImaginaryThreshold=NumTraits< Scalar >::dummy_precision()) const |
| const RootType & | smallestRoot () const |
Protected Member Functions | |
| template<typename OtherPolynomial> | |
| void | cleanUpRoots (const OtherPolynomial &poly) |
| template<typename OtherPolynomial> | |
| void | refineRoots (const OtherPolynomial &poly) |
|
inlineprotected |
Restores the structure the in-place iteration keeps only to within rounding. The roots of a real polynomial are real or conjugate pairs: two iterates closer to each other's conjugate than to the real axis become exactly conjugate, and an iterate left without a partner becomes real. Residual-based snapping of the remaining roots requires an imaginary part at most sqrt(eps) times the real part and a finite rounding bound.
|
inline |
Computes the complex roots of a new polynomial. With refine, the eigenvalues of the companion matrix are refined by Ehrlich-Aberth iterations before the clean-up, see the class documentation.
|
inlineprotected |
Refines the eigenvalue estimates in m_roots by Ehrlich-Aberth iterations (Ehrlich 1967; Aberth 1973), \( z_i \leftarrow z_i - w_i / (1 - w_i \sum_{j \ne i} (z_i - z_j)^{-1}) \) with \( w_i = p(z_i) / p'(z_i) \). The iteration is cubic for simple roots, and the sum keeps the iterates apart, so every root is refined at once without deflation. Updates use the latest estimates; real starting values receive an epsilon-sized imaginary perturbation so they can reach nonreal roots. At the sweep limit, unfinished estimates are compared with their initial polynomial residuals. A root is final once \( |p(z_i)| \) is within the rounding bound of its evaluation, so that \( z_i \) is an exact root of a polynomial that close to \( p \) (the stopping rule of Bini 1996), or once its Newton correction is below one ulp.