13 #ifndef ROOT_Math_Util 14 #define ROOT_Math_Util 26 #ifndef ROOT_Math_VecTypes 33 #define MATH_UNUSED(var) (void)var 51 std::ostringstream buf;
54 std::string ret = buf.str();
64 static const T epsilon =
T(2.0 * std::numeric_limits<double>::min());
95 KahanSum(
const T &initialValue =
T{}) : fSum(initialValue) {}
100 auto y = x - fCorrection;
102 fCorrection = (t - fSum) - y;
107 template <
class Iterator>
108 void Add(
const Iterator begin,
const Iterator end)
110 static_assert(!std::is_same<decltype(*begin),
T>::value,
111 "Iterator points to an element of the different type than the KahanSum class");
112 for (
auto it = begin; it != end; it++) this->
Add(*it);
117 template <
class Iterator>
118 static T Accumulate(
const Iterator begin,
const Iterator end,
const T &initialValue =
T{})
120 static_assert(!std::is_same<decltype(*begin),
T>::value,
121 "Iterator points to an element of the different type than the KahanSum class");
123 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.