Solve a cubic with real coefficients and complex roots (CERNLIB) More...
#include <poly.h>
Public Member Functions | |
virtual int | solve_rc (const double a3, const double b3, const double c3, const double d3, double &x1, std::complex< double > &x2, std::complex< double > &x3) |
Solves the polynomial ![]() ![]() ![]() ![]() | |
virtual int | rrteq3 (double r, double s, double t, double x[], double &d) |
The CERNLIB-like interface. More... | |
const char * | type () |
Return a string denoting the type ("cubic_real_coeff_cern") | |
![]() | |
virtual int | solve_r (const double a3, const double b3, const double c3, const double d3, double &x1, double &x2, double &x3) |
Solves the polynomial ![]() ![]() ![]() ![]() | |
const char * | type () |
Return a string denoting the type ("cubic_real_coeff") | |
![]() | |
const char * | type () |
Return a string denoting the type ("cubic_real") | |
Public Attributes | |
double | eps |
Numerical tolerance (default ![]() | |
double | delta |
Numerical tolerance (default ![]() | |
bool | improve_scale |
Improve algorithm for poorly-scaled roots (default true) | |
|
virtual |
This function computes the roots of the cubic equation
returning the value of the discriminant in d
and the roots in the array x
. If the discriminant is negative, then all three real roots are stored in x
. Otherwise, the real root is stored in x[0]
and the real and imaginary parts of the complex conjugate roots are stored in x[1]
and x[2]
, respectively. This differs from the CERNLIB routine where the results were stored in x[1]
, x[2]
, and x[3]
instead.
Another small change is that the discriminant for the resolvent cubic is evaluated slightly differently in order to improve the properties in the case where the roots are not all of order unity. The default CERNLIB behavior can be restored by setting improve_scale to false
.
Documentation generated with Doxygen. Provided under the
GNU Free Documentation License (see License Information).