Object-oriented Scientific Computing Library: Version 0.910
Public Member Functions | Data Fields
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

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

Definition at line 380 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 CERNLIB-like 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 poorly-scaled roots (default true)

Member Function Documentation

virtual int cern_cubic_real_coeff::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:
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

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

Get Object-oriented Scientific Computing
Lib at SourceForge.net. Fast, secure and Free Open Source software
downloads.