cern_cubic_real_coeff Class Reference

Solve a cubic with real coefficients and complex roots (CERNLIB). More...

#include <poly.h>

Inheritance diagram for cern_cubic_real_coeff:

cubic_real_coeff cubic_real

Detailed Description

Solve a cubic with real coefficients and complex roots (CERNLIB).

This follows the original Fortran code except in the function rrteq3(), the roots are returned in x[0], x[1], and x[2] instead of x[1], x[2], and x[3]. (The arrays y and z were already zero-indexed in the CERN routine.) Similar to the original, in the case of complex roots, x[0] is the real root and x[1] and x[2] contain the real and imaginary parts of the complex roots.

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 of order unity. The default CERNLIB behavior can be restored by setting improve_scale to false.

Definition at line 403 of file 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 $ a_3 x^3 + b_3 x^2 + c_3 x + d_3= 0 $ giving the real solution $ x=x_1 $ and two complex solutions $ x=x_1 $ , $ x=x_2 $ , and $ x=x_3 $ .
virtual int rrteq3 (double r, double s, double t, double x[], double &d)
 The original CERNLIB interface.
const char * type ()
 Return a string denoting the type ("cern_cubic_real_coeff").

Data Fields

double eps
 Numerical tolerance (default $ 10^{-6} $).
double delta
 Numerical tolerance (default $ 10^{-15} $).
bool improve_scale
 Improve algorithm for bad-scaled roots (default true).

The documentation for this class was generated from the following file:

Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.

Project hosting provided by SourceForge.net Logo, O2scl Sourceforge Project Page