28#ifndef ROOT_Math_VecTypes
35#define MATH_UNUSED(var) (void)var
50 TimingScope(std::function<
void(std::string
const&)>
printer, std::string
const &message);
55 std::chrono::steady_clock::time_point
fBegin;
56 std::function<void(std::string
const&)>
fPrinter;
66 std::ostringstream buf;
69 std::string
ret = buf.str();
79 static const T epsilon = T(2.0 * std::numeric_limits<double>::min());
81 if constexpr (std::is_arithmetic_v<T>) {
82 return x <= epsilon ?
x / epsilon + std::log(epsilon) - T(1.0) : std::log(
x);
86 auto mask =
x <= epsilon;
140 template<
typename T =
double,
unsigned int N = 1>
147 std::fill(std::begin(
fSum)+1, std::end(
fSum), 0.);
157 std::fill(std::begin(
fSum)+1, std::end(
fSum), 0.);
166 template<
class Iterator>
175 template <
unsigned int M>
179 std::fill(std::begin(
fSum)+1, std::end(
fSum), 0.);
186 auto t =
fSum[0] +
y;
198 template <
class Iterator>
199 void Add(Iterator begin, Iterator end) {
200 static_assert(std::is_floating_point<
201 typename std::remove_reference<
decltype(*begin)>
::type>
::value,
202 "Iterator needs to point to floating-point values.");
203 const std::size_t
n = std::distance(begin, end);
205 for (std::size_t i=0; i<
n; ++i) {
213 template<
class Container_t>
215 static_assert(std::is_floating_point<typename Container_t::value_type>::value,
216 "Container does not hold floating-point values.");
217 for (std::size_t i=0; i <
inputs.size(); ++i) {
229 template <
class Iterator>
251 const unsigned int i =
index %
N;
253 const T t =
fSum[i] +
y;
260 return std::accumulate(std::begin(
fSum), std::end(
fSum), 0.);
270 return std::accumulate(std::begin(
fCarry), std::end(
fCarry), 0.);
295 template<
typename U,
unsigned int M>
308 template<
typename U,
unsigned int M>
323 template<
typename U,
unsigned int M>
325 return (this->
Sum() == other.Sum()) && (this->
Carry() == other.Carry());
328 template<
typename U,
unsigned int M>
330 return !(*
this ==
other);
339 template<
typename T,
unsigned int N,
typename U,
unsigned int M>
347 template<
typename T,
unsigned int N,
typename U,
unsigned int M>
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
The Kahan summation is a compensated summation algorithm, which significantly reduces numerical error...
bool operator==(KahanSum< U, M > const &other) const
KahanSum< T, N > operator-()
static KahanSum< T, N > Accumulate(Iterator begin, Iterator end, T initialValue=T{})
Iterate over a range and return an instance of a KahanSum.
void Add(Iterator begin, Iterator end)
Accumulate from a range denoted by iterators.
void Add(const Container_t &inputs)
Fill from a container that supports index access.
KahanSum(KahanSum< T, M > const &other)
Constructor to create a KahanSum from another KahanSum with a different number of accumulators.
bool operator!=(KahanSum< U, M > const &other) const
void AddIndexed(T input, std::size_t index)
Add input to the sum.
KahanSum< T, N > & operator+=(T arg)
Add arg into accumulator. Does not vectorise.
KahanSum< T, N > & operator+=(const KahanSum< U, M > &other)
Add other KahanSum into accumulator.
KahanSum(T initialValue=T{})
Initialise the sum.
KahanSum(T initialSumValue, T initialCarryValue)
Initialise with a sum value and a carry value.
void Add(T x)
Single-element accumulation. Will not vectorise.
KahanSum< T, N > & operator-=(KahanSum< U, M > const &other)
Subtract other KahanSum.
KahanSum(Iterator sumBegin, Iterator sumEnd, Iterator carryBegin, Iterator carryEnd)
Initialise the sum with a pre-existing state.
std::chrono::steady_clock::time_point fBegin
const std::string fMessage
std::function< void(std::string const &) fPrinter)
TimingScope(std::function< void(std::string const &)> printer, std::string const &message)
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.
DisplacementVector2D< CoordSystem1, U > operator+(DisplacementVector2D< CoordSystem1, U > v1, const DisplacementVector2D< CoordSystem2, U > &v2)
Addition of DisplacementVector2D vectors.
DisplacementVector2D< CoordSystem1, U > operator-(DisplacementVector2D< CoordSystem1, U > v1, DisplacementVector2D< CoordSystem2, U > const &v2)
Difference between two DisplacementVector2D vectors.
static uint64_t sum(uint64_t i)