Public Member Functions | Public Attributes | List of all members
o2scl::cubic_real_coeff_cern Class Reference

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

#include <poly.h>

Inheritance diagram for o2scl::cubic_real_coeff_cern:
o2scl::cubic_real_coeff o2scl::cubic_real

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_2 $ , and $ x=x_3 $ .
 
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")
 
- Public Member Functions inherited from o2scl::cubic_real_coeff
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 $ a_3 x^3 + b_3 x^2 + c_3 x + d_3= 0 $ giving the three solutions $ x=x_1 $ , $ x=x_2 $ , and $ x=x_3 $ .
 
const char * type ()
 Return a string denoting the type ("cubic_real_coeff")
 
- Public Member Functions inherited from o2scl::cubic_real
const char * type ()
 Return a string denoting the type ("cubic_real")
 

Public Attributes

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

Detailed Description

Note
The function rrteq3() is based on the CERNLIB routine of the same name, but differs slightly. See the documentation of that function for details.

Definition at line 379 of file poly.h.

Member Function Documentation

◆ rrteq3()

virtual int o2scl::cubic_real_coeff_cern::rrteq3 ( double  r,
double  s,
double  t,
double  x[],
double &  d 
)
virtual

This function computes the roots of the cubic equation

\[ x^3 + r x^2 + s x + t =0 \]

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.


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

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).