Find the roots of a real polynomial. More...
#include <vnl_rpoly_roots.h>
Public Member Functions | |
| vnl_rpoly_roots (const vnl_vector< double > &a) | |
| The constructor calculates the roots. More... | |
| vnl_rpoly_roots (const vnl_real_polynomial &poly) | |
| Calculate roots of a vnl_real_polynomial. Same comments apply. More... | |
| std::complex< double > | operator [] (int i) const |
| Return i'th complex root. More... | |
| vnl_vector< std::complex< double > > | roots () const |
| Complex vector of all roots. More... | |
| const double & | real (int i) const |
| Real part of root I. More... | |
| const double & | imag (int i) const |
| Imaginary part of root I. More... | |
| vnl_vector< double > & | real () |
| Vector of real parts of roots. More... | |
| vnl_vector< double > & | imag () |
| Vector of imaginary parts of roots. More... | |
| vnl_vector< double > | realroots (double tol=1e-12) const |
| Return real roots only. More... | |
| bool | compute () |
| Compute roots using Jenkins-Traub algorithm. More... | |
| bool | compute_qr () |
| Compute roots using QR decomposition of companion matrix. [unimplemented]. More... | |
| bool | compute_laguerre () |
| Compute roots using Laguerre algorithm. [unimplemented]. More... | |
Protected Attributes | |
| vnl_vector< double > | coeffs_ |
| vnl_vector< double > | r_ |
| vnl_vector< double > | i_ |
| int | num_roots_found_ |
Find the roots of a real polynomial.
Uses algorithm 493 from ACM Trans. Math. Software - the Jenkins-Traub algorithm, described by Numerical Recipes under "Other sure-fire techniques" as "practically a standard in black-box polynomial rootfinders". (See M.A. Jenkins, ACM TOMS 1 (1975) pp. 178-189.).
This class is not very const-correct as it is intended as a compute object rather than a data object.
Definition at line 37 of file vnl_rpoly_roots.h.
| vnl_rpoly_roots::vnl_rpoly_roots | ( | const vnl_vector< double > & | a | ) |
The constructor calculates the roots.
This is the most efficient interface as all the result variables are initialized to the correct size. The polynomial is
.
Note that if the routine fails, not all roots will be found. In this case, the "realroots" and "roots" functions will return fewer than n roots.
Definition at line 22 of file vnl_rpoly_roots.cxx.
| vnl_rpoly_roots::vnl_rpoly_roots | ( | const vnl_real_polynomial & | poly | ) |
Calculate roots of a vnl_real_polynomial. Same comments apply.
Definition at line 33 of file vnl_rpoly_roots.cxx.
| bool vnl_rpoly_roots::compute | ( | ) |
Compute roots using Jenkins-Traub algorithm.
Calls rpoly and interprets failure codes.
Definition at line 71 of file vnl_rpoly_roots.cxx.
| bool vnl_rpoly_roots::compute_laguerre | ( | ) |
Compute roots using Laguerre algorithm. [unimplemented].
| bool vnl_rpoly_roots::compute_qr | ( | ) |
Compute roots using QR decomposition of companion matrix. [unimplemented].
|
inline |
Imaginary part of root I.
Definition at line 67 of file vnl_rpoly_roots.h.
|
inline |
Vector of imaginary parts of roots.
Definition at line 73 of file vnl_rpoly_roots.h.
|
inline |
Return i'th complex root.
Definition at line 58 of file vnl_rpoly_roots.h.
|
inline |
Real part of root I.
Definition at line 64 of file vnl_rpoly_roots.h.
|
inline |
Vector of real parts of roots.
Definition at line 70 of file vnl_rpoly_roots.h.
| vnl_vector< double > vnl_rpoly_roots::realroots | ( | double | tol = 1e-12 | ) | const |
Return real roots only.
Roots are real if the absolute value of their imaginary part is less than the optional argument TOL. TOL defaults to 1e-12 [untested]
Definition at line 53 of file vnl_rpoly_roots.cxx.
| vnl_vector< std::complex< double > > vnl_rpoly_roots::roots | ( | ) | const |
Complex vector of all roots.
Definition at line 42 of file vnl_rpoly_roots.cxx.
|
protected |
Definition at line 93 of file vnl_rpoly_roots.h.
|
protected |
Definition at line 96 of file vnl_rpoly_roots.h.
|
protected |
Definition at line 98 of file vnl_rpoly_roots.h.
|
protected |
Definition at line 95 of file vnl_rpoly_roots.h.
1.8.15