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. | |
vnl_rpoly_roots (const vnl_real_polynomial &poly) | |
Calculate roots of a vnl_real_polynomial. Same comments apply. | |
vcl_complex< double > | operator[] (int i) const |
Return i'th complex root. | |
vnl_vector< vcl_complex< double > > | roots () const |
Complex vector of all roots. | |
const double & | real (int i) const |
Real part of root I. | |
const double & | imag (int i) const |
Imaginary part of root I. | |
vnl_vector< double > & | real () |
Vector of real parts of roots. | |
vnl_vector< double > & | imag () |
Vector of imaginary parts of roots. | |
vnl_vector< double > | realroots (double tol=1e-12) const |
Return real roots only. | |
bool | compute () |
Compute roots using Jenkins-Traub algorithm. | |
bool | compute_qr () |
Compute roots using QR decomposition of companion matrix. [unimplemented]. | |
bool | compute_laguerre () |
Compute roots using Laguerre algorithm. [unimplemented]. | |
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 36 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 25 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 36 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 74 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].
const double& vnl_rpoly_roots::imag | ( | int | i | ) | const [inline] |
Imaginary part of root I.
Definition at line 66 of file vnl_rpoly_roots.h.
vnl_vector<double>& vnl_rpoly_roots::imag | ( | ) | [inline] |
Vector of imaginary parts of roots.
Definition at line 72 of file vnl_rpoly_roots.h.
vcl_complex<double> vnl_rpoly_roots::operator[] | ( | int | i | ) | const [inline] |
Return i'th complex root.
Definition at line 57 of file vnl_rpoly_roots.h.
const double& vnl_rpoly_roots::real | ( | int | i | ) | const [inline] |
Real part of root I.
Definition at line 63 of file vnl_rpoly_roots.h.
vnl_vector<double>& vnl_rpoly_roots::real | ( | ) | [inline] |
Vector of real parts of roots.
Definition at line 69 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 56 of file vnl_rpoly_roots.cxx.
vnl_vector< vcl_complex< double > > vnl_rpoly_roots::roots | ( | ) | const |
Complex vector of all roots.
Definition at line 45 of file vnl_rpoly_roots.cxx.
vnl_vector<double> vnl_rpoly_roots::coeffs_ [protected] |
Definition at line 92 of file vnl_rpoly_roots.h.
vnl_vector<double> vnl_rpoly_roots::i_ [protected] |
Definition at line 95 of file vnl_rpoly_roots.h.
int vnl_rpoly_roots::num_roots_found_ [protected] |
Definition at line 97 of file vnl_rpoly_roots.h.
vnl_vector<double> vnl_rpoly_roots::r_ [protected] |
Definition at line 94 of file vnl_rpoly_roots.h.