13 #ifndef __UT_Accumulator__
14 #define __UT_Accumulator__
28 mySum(init_val), myCompensation(
T(0.0)) { }
36 myCompensation += (mySum -
t) + rhs;
38 myCompensation += (rhs -
t) + mySum;
43 T sum()
const {
return mySum + myCompensation; }
50 template <
typename T,
int S>
57 mySum(init_val), myCompensation(
T(0.0)) { }
62 for (
int i = 0, ie =
S; i < ie; i++)
64 T t = mySum(i) + rhs(i);
66 myCompensation(i) += (mySum(i) -
t) + rhs(i);
68 myCompensation(i) += (rhs(i) -
t) + mySum(i);
74 V sum()
const {
return mySum + myCompensation; }
86 using C = std::complex<T>;
89 mySum(init_val), myCompensation(
C(0.0)) { }
94 T t = mySum.real() + rhs.real();
96 myCompensation.real(myCompensation.real()
97 + (mySum.real() -
t) + rhs.real());
99 myCompensation.real(myCompensation.real()
100 + (rhs.real() -
t) + mySum.real());
103 t = mySum.imag() + rhs.imag();
105 myCompensation.imag(myCompensation.imag()
106 + (mySum.imag() -
t) + rhs.imag());
108 myCompensation.imag(myCompensation.imag()
109 + (rhs.imag() -
t) + mySum.imag());
115 C sum()
const {
return mySum + myCompensation; }
125 template <
typename T>
Accumulator(const T &init_val=T(0.0))
SYS_FORCE_INLINE C & operator+=(const C &rhs)
SYS_FORCE_INLINE V & operator+=(const V &rhs)
Accumulator(const C &init_val=C(0.0))
SYS_FORCE_INLINE T & operator+=(const T &rhs)
Accumulator(const V &init_val=V(T(0.0)))