CMS 3D CMS Logo

Public Member Functions | Public Attributes

RealQuadEquation Struct Reference

#include <RealQuadEquation.h>

List of all members.

Public Member Functions

 RealQuadEquation (double A, double B, double C)

Public Attributes

double first
bool hasSolution
double second

Detailed Description

A numericaly stable and as fast as can be quadratic equation solver. The equation has the form A*x^2 + B*x + C = 0

Definition at line 11 of file RealQuadEquation.h.


Constructor & Destructor Documentation

RealQuadEquation::RealQuadEquation ( double  A,
double  B,
double  C 
) [inline]

Definition at line 17 of file RealQuadEquation.h.

References funct::A, funct::C, funct::D, first, hasSolution, lumiQueryAPI::q, second, and mathSSE::sqrt().

                                                  {
    double D = B*B - 4*A*C;
    if (D<0) hasSolution = false;
    else {
      hasSolution = true;
      double q = -0.5*(B + (B>0 ? sqrt(D) : -sqrt(D)));
      first = q/A;
      second = C/q;
    }
  }

Member Data Documentation