BornAgain
1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
|
The Kahan compensate summation algorithm significantly reduces the numerical error in the total obtained by adding a sequence of finite precision floating point numbers. This is done by keeping a separate running compensation (a variable to accumulate small errors).
.
The intial values of the result and the correction are set to the default value of the type it hass been instantiated with.
Public Member Functions | |
KahanSum (const T &initialValue=T{}) | |
Constructor accepting a initial value for the summation as parameter. More... | |
template<class Iterator > | |
void | Add (const Iterator begin, const Iterator end) |
Iterate over a datastructure referenced by a pointer and accumulate on the exising result. More... | |
void | Add (const T &x) |
Single element accumulated addition. More... | |
T | Result () |
Return the result. More... | |
Static Public Member Functions | |
template<class Iterator > | |
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. Can take an initial value as third parameter. More... | |
Private Attributes | |
T | fCorrection {} |
T | fSum {} |
|
inline |
|
inlinestatic |
Iterate over a datastructure referenced by a pointer and return the result of its accumulation. Can take an initial value as third parameter.
Definition at line 111 of file Util.h.
|
inline |
Iterate over a datastructure referenced by a pointer and accumulate on the exising result.
Definition at line 101 of file Util.h.
References ROOT::Math::KahanSum< T >::Add().
|
inline |
Single element accumulated addition.
Definition at line 91 of file Util.h.
References ROOT::Math::KahanSum< T >::fCorrection, and ROOT::Math::KahanSum< T >::fSum.
Referenced by ROOT::Math::KahanSum< T >::Add().
|
inline |
Return the result.
Definition at line 121 of file Util.h.
References ROOT::Math::KahanSum< T >::fSum.
|
private |
Definition at line 125 of file Util.h.
Referenced by ROOT::Math::KahanSum< T >::Add().
|
private |
Definition at line 124 of file Util.h.
Referenced by ROOT::Math::KahanSum< T >::Add(), and ROOT::Math::KahanSum< T >::Result().