| 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 |
| 16 |
#include <string> |
#include <string> |
| 17 |
#include <sstream> |
#include <sstream> |
| 18 |
|
|
| 19 |
|
#include <cmath> |
| 20 |
|
#include <limits> |
| 21 |
|
|
| 22 |
namespace ROOT { |
namespace ROOT { |
| 23 |
|
|
| 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 |
|
|