[root] / trunk / math / mathcore / inc / Math / Util.h Repository:
ViewVC logotype

Diff of /trunk/math/mathcore/inc/Math/Util.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 25485, Mon Sep 22 07:52:52 2008 UTC revision 25486, Mon Sep 22 12:43:03 2008 UTC
# Line 8  Line 8 
8   *                                                                    *   *                                                                    *
9   **********************************************************************/   **********************************************************************/
10    
11  // Utility functions for all ROOT Math  // Utility functions for all ROOT Math classes
12    
13  #ifndef ROOT_Math_Util  #ifndef ROOT_Math_Util
14  #define ROOT_Math_Util  #define ROOT_Math_Util
# Line 16  Line 16 
16  #include <string>  #include <string>
17  #include <sstream>  #include <sstream>
18    
19    #include <cmath>
20    #include <limits>
21    
22  namespace ROOT {  namespace ROOT {
23    
# Line 41  Line 43 
43     return ret;     return ret;
44  }  }
45    
46    
47    /// safe evaluation of log(x) with a protections against negative or zero argument to the log
48    /// smooth linear extrapolation below function values smaller than  epsilon
49    /// (better than a simple cut-off)
50    inline double EvalLog(double x) {
51       // evaluate the log
52       const static double epsilon = 2.*std::numeric_limits<double>::min();
53       if(x<= epsilon)
54          return x/epsilon + std::log(epsilon) - 1;
55       else
56          return std::log(x);
57    }
58    
59  }  // end namespace Util  }  // end namespace Util
60    
61    

Legend:
Removed from v.25485  
changed lines
  Added in v.25486

Subversion Admin
ViewVC Help
Powered by ViewVC 1.0.9