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());
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);
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.
void Add(const T &x)
Single element accumulated addition.
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.
KahanSum(const T &initialValue=T{})
Constructor accepting a initial value for the summation as parameter.
T Result()
Return the result.
Namespace for new Math classes and functions.
T EvalLog(T x)
safe evaluation of log(x) with a protections against negative or zero argument to the log smooth line...
std::string ToString(const T &val)
Utility function for conversion to strings.
Namespace for new ROOT classes and functions.