Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix indentation 🎨
  • Loading branch information
xvallspl committed Apr 6, 2017
commit 5f819428ca47241bbe75afab7759c01091e15770
74 changes: 37 additions & 37 deletions math/mathcore/inc/Math/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,42 +31,43 @@ namespace ROOT {
namespace Math {


/**
namespace defining Utility functions needed by mathcore
*/
namespace Util {

/**
Utility function for conversion to strings
*/
template<class T>
std::string ToString(const T& val)
{
std::ostringstream buf;
buf << val;

std::string ret = buf.str();
return ret;
}


/// safe evaluation of log(x) with a protections against negative or zero argument to the log
/// smooth linear extrapolation below function values smaller than epsilon
/// (better than a simple cut-off)
inline double EvalLog(double x) {
// evaluate the log
#ifdef __CINT__
static const double epsilon = 2.*2.2250738585072014e-308;
#else
static const double epsilon = 2.*std::numeric_limits<double>::min();
#endif
if(x<= epsilon)
return x/epsilon + std::log(epsilon) - 1;
else
return std::log(x);
}

} // end namespace Util
/**
namespace defining Utility functions needed by mathcore
*/
namespace Util {

/**
Utility function for conversion to strings
*/
template<class T>
std::string ToString(const T &val)
{
std::ostringstream buf;
buf << val;

std::string ret = buf.str();
return ret;
}


/// safe evaluation of log(x) with a protections against negative or zero argument to the log
/// smooth linear extrapolation below function values smaller than epsilon
/// (better than a simple cut-off)
inline double EvalLog(double x)
{
// evaluate the log
#ifdef __CINT__
static const double epsilon = 2.*2.2250738585072014e-308;
#else
static const double epsilon = 2.*std::numeric_limits<double>::min();
#endif
if (x <= epsilon)
return x / epsilon + std::log(epsilon) - 1;
else
return std::log(x);
}

} // end namespace Util

template<class T>
class KahanSum {
Expand Down Expand Up @@ -107,5 +108,4 @@ inline double EvalLog(double x) {
} // end namespace ROOT



#endif /* ROOT_Math_Util */