LibreOffice Module sc (master) 1
|
This class provides LO with Kahan summation algorithm About this algorithm: https://en.wikipedia.org/wiki/Kahan_summation_algorithm For general purpose software we assume first order error is enough. More...
#include <kahan.hxx>
Public Member Functions | |
constexpr | KahanSum ()=default |
constexpr | KahanSum (double x_0) |
constexpr | KahanSum (double x_0, double err_0) |
constexpr | KahanSum (const KahanSum &fSum)=default |
void | add (double x_i) |
Adds a value to the sum using Kahan summation. More... | |
void | add (const KahanSum &fSum) |
Adds a value to the sum using Kahan summation. More... | |
void | subtract (const KahanSum &fSum) |
Substracts a value to the sum using Kahan summation. More... | |
constexpr KahanSum | operator- () const |
constexpr KahanSum & | operator= (double fSum) |
constexpr KahanSum & | operator= (const KahanSum &fSum)=default |
void | operator+= (const KahanSum &fSum) |
void | operator+= (double fSum) |
void | operator-= (const KahanSum &fSum) |
void | operator-= (double fSum) |
KahanSum | operator+ (double fSum) const |
KahanSum | operator+ (const KahanSum &fSum) const |
KahanSum | operator- (double fSum) const |
KahanSum | operator- (const KahanSum &fSum) const |
constexpr void | operator*= (double fTimes) |
In some parts of the code of interpr_.cxx this may be used for product instead of sum. More... | |
constexpr void | operator/= (double fDivides) |
KahanSum | operator* (const KahanSum &fTimes) const |
KahanSum | operator* (double fTimes) const |
KahanSum | operator/ (const KahanSum &fDivides) const |
KahanSum | operator/ (double fDivides) const |
bool | operator< (const KahanSum &fSum) const |
bool | operator< (double fSum) const |
bool | operator> (const KahanSum &fSum) const |
bool | operator> (double fSum) const |
bool | operator<= (const KahanSum &fSum) const |
bool | operator<= (double fSum) const |
bool | operator>= (const KahanSum &fSum) const |
bool | operator>= (double fSum) const |
bool | operator== (const KahanSum &fSum) const |
bool | operator!= (const KahanSum &fSum) const |
double | get () const |
Returns the final sum. More... | |
Private Attributes | |
double | m_fSum = 0 |
double | m_fError = 0 |
double | m_fMem = 0 |
This class provides LO with Kahan summation algorithm About this algorithm: https://en.wikipedia.org/wiki/Kahan_summation_algorithm For general purpose software we assume first order error is enough.
Additionally queue and remember the last recent non-zero value and add it similar to approxAdd() when obtaining the final result to further eliminate accuracy errors. (e.g. for the dreaded 0.1 + 0.2 - 0.3 != 0.0)
|
constexprdefault |
|
inlineconstexpr |
|
constexprdefault |
|
inline |
|
inline |
Adds a value to the sum using Kahan summation.
x_i |
Definition at line 48 of file kahan.hxx.
References m_fError, m_fMem, m_fSum, and t.
Referenced by add(), get(), operator+(), operator+=(), operator-(), operator-=(), and subtract().
|
inline |
Returns the final sum.
Definition at line 211 of file kahan.hxx.
References add(), m_fError, m_fMem, and m_fSum.
Referenced by ScInterpreter::CalculatePearsonCovar(), ScInterpreter::CalculateSkewOrSkewp(), ScInterpreter::CalculateSlopeIntercept(), ScInterpreter::CalculateSumX2MY2SumX2DY2(), ScInterpreter::CalculateTest(), ScInterpreter::DBIterator(), ScInterpreter::GetDBStVarParams(), ScInterpreter::GetStVarParams(), ScInterpreter::IterateParameters(), ScInterpreter::IterateParametersIf(), lcl_GetBinomDistRange(), lcl_IterateInverse(), lcl_LUP_solve(), operator!=(), operator*(), operator*=(), operator/(), operator/=(), operator<(), operator<=(), operator==(), operator>(), operator>=(), ScInterpreter::ScAveDev(), ScInterpreter::ScChiTest(), ScInterpreter::ScCumIpmt(), ScInterpreter::ScCumPrinc(), ScInterpreter::ScForecast(), ScInterpreter::ScGeoMean(), ScInterpreter::ScHarMean(), ScInterpreter::ScHypGeomDist(), ScInterpreter::ScInterVDB(), ScInterpreter::ScIRR(), ScInterpreter::ScKurt(), ScInterpreter::ScMatMult(), ScInterpreter::ScMIRR(), ScInterpreter::ScNPV(), ScInterpreter::ScPoissonDist(), ScInterpreter::ScProbability(), ScInterpreter::ScSumProduct(), ScInterpreter::ScTrimMean(), ScInterpreter::ScTTest(), ScInterpreter::ScVDB(), ScInterpreter::ScZTest(), sc::op::sumArray(), and ScInterpreter::taylor().
|
inline |
Definition at line 178 of file kahan.hxx.
References sc::fTimes, and get().
|
inline |
Definition at line 180 of file kahan.hxx.
References sc::fTimes, and get().
|
inlineconstexpr |
|
inline |
|
inline |
|
inline |
|
inlineconstexpr |
|
inline |
|
inline |
Definition at line 114 of file kahan.hxx.
References subtract().
|
inline |
|
inline |
|
inlineconstexpr |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlineconstexpr |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
private |
Definition at line 236 of file kahan.hxx.
Referenced by add(), get(), operator*=(), operator-(), operator/=(), operator=(), and subtract().
|
private |
Definition at line 237 of file kahan.hxx.
Referenced by add(), get(), operator*=(), operator-(), operator/=(), operator=(), and subtract().
|
private |
Definition at line 235 of file kahan.hxx.
Referenced by add(), get(), operator*=(), operator-(), operator/=(), operator=(), and subtract().