| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

MathHelperFun.h

Go to the documentation of this file.
00001 // $Id: MathHelperFun.h,v 1.1 2006/05/31 13:38:31 jpalac Exp $
00002 #ifndef KERNEL_MATHHELPERFUN_H 
00003 #define KERNEL_MATHHELPERFUN_H 1
00004 
00005 // Include files
00006 
00013 namespace Gaudi {
00014   namespace Math 
00015   {
00016 
00025     template < class OUTPUTTYPE > 
00026     inline unsigned int 
00027     SolveQuadraticEquation( const double a, 
00028                             const double b, 
00029                             const double c,
00030                             OUTPUTTYPE   out ) 
00031     {
00032       if( 0 == a ) // it is indeed  a linear equation:  b*x + c = 0 
00033       {
00034         // no solution!
00035         if( b == 0 ) { return 0 ; }   // RETURN !!! 
00036         // 1 solution!
00037         *out++ = -1.0 * c / b ; 
00038         *out++ = -1.0 * c / b ;       // double the solutions 
00039         return 1;                     // RETURN !!!   
00040       }
00041       double d = b * b - 4.0 * a * c ; 
00042       // no solutions 
00043       if(  d < 0  )   { return 0; }     // RETURN !!!
00044       // 1 or 2 solution
00045       d = sqrt( d )                  ;   
00046       *out++ = 0.5 * ( -b - d ) / a  ; 
00047       *out++ = 0.5 * ( -b + d ) / a  ; 
00048       // return number of solutions;
00049       return 0 == d ? 1 : 2 ;           // RETURN !!! 
00050     };
00051 
00052 
00053   }; // Math namespace
00054    
00055 }; // Gaudi namespace
00056 #endif // KERNEL_MATHHELPERFUN_H
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:02:57 2011 for LHCbMath by doxygen 1.4.7