13 #ifndef ROOT_Math_Util 14 #define ROOT_Math_Util 26 #define MATH_UNUSED(var) (void)var 44 std::ostringstream buf;
47 std::string ret = buf.str();
57 static const T epsilon =
T(2.0 * std::numeric_limits<double>::min());
58 #if !defined(R__HAS_VECCORE) 88 KahanSum(
const T &initialValue =
T{}) : fSum(initialValue) {}
93 auto y = x - fCorrection;
95 fCorrection = (t - fSum) - y;
100 template <
class Iterator>
101 void Add(
const Iterator begin,
const Iterator end)
103 static_assert(!std::is_same<decltype(*begin),
T>::value,
104 "Iterator points to an element of the different type than the KahanSum class");
105 for (
auto it = begin; it != end; it++) this->
Add(*it);
110 template <
class Iterator>
111 static T Accumulate(
const Iterator begin,
const Iterator end,
const T &initialValue =
T{})
113 static_assert(!std::is_same<decltype(*begin),
T>::value,
114 "Iterator points to an element of the different type than the KahanSum class");
116 init.
Add(begin, end);
Namespace for new ROOT classes and functions.
KahanSum(const T &initialValue=T{})
Constructor accepting a initial value for the summation as parameter.
T Result()
Return the result.
The Kahan compensate summation algorithm significantly reduces the numerical error in the total obtai...
void Add(const Iterator begin, const Iterator end)
Iterate over a datastructure referenced by a pointer and accumulate on the exising result...
T EvalLog(T x)
safe evaluation of log(x) with a protections against negative or zero argument to the log smooth line...
static T Accumulate(const Iterator begin, const Iterator end, const T &initialValue=T{})
Iterate over a datastructure referenced by a pointer and return the result of its accumulation...
void Add(THist< DIMENSIONS, PRECISION_TO, STAT_TO... > &to, const THist< DIMENSIONS, PRECISION_FROM, STAT_FROM... > &from)
Add two histograms.
Namespace for new Math classes and functions.
std::string ToString(const T &val)
Utility function for conversion to strings.
void Add(const T &x)
Single element accumulated addition.