summaryrefslogtreecommitdiff
path: root/sc/inc/dptabres.hxx
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2018-12-11 23:48:37 +0100
committerEike Rathke <erack@redhat.com>2018-12-12 01:26:01 +0100
commit3c964980da07892a02d5ac721d80558c459532d0 (patch)
tree6aad0644fba0f8372cce7e053c38ba8ed292eadc /sc/inc/dptabres.hxx
parentd1363c39201e93aa83028fd837fe12f48f79f63b (diff)
Use Welford one-pass variance algorithm for DataPilot / pivot table
... instead of the naïve algorithm. Short test case with 4 values: 10000000007 10000000011 10000000013 10000000017 Naïve Var: -21845.3333333333 Welford Var: 17.3333314259847 VAR() two-pass: 17.3333333333333 Change-Id: I2f27ab91166551e96c0e467f41bd6e6d49b50295 Reviewed-on: https://gerrit.libreoffice.org/64993 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins
Diffstat (limited to 'sc/inc/dptabres.hxx')
-rw-r--r--sc/inc/dptabres.hxx14
1 files changed, 8 insertions, 6 deletions
diff --git a/sc/inc/dptabres.hxx b/sc/inc/dptabres.hxx
index d28e192863c6..0a20f3cffa76 100644
--- a/sc/inc/dptabres.hxx
+++ b/sc/inc/dptabres.hxx
@@ -24,6 +24,7 @@
#include "dpfilteredcache.hxx"
#include "calcmacros.hxx"
#include "dpitemdata.hxx"
+#include "subtotal.hxx"
#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
#include <com/sun/star/sheet/DataPilotFieldReference.hpp>
@@ -144,18 +145,19 @@ struct ScDPRelativePos
// Possible values for the nCount member:
// (greater than 0 counts the collected values)
-const long SC_DPAGG_EMPTY = 0; // empty during data collection
-const long SC_DPAGG_DATA_ERROR = -1; // error during data collection
-const long SC_DPAGG_RESULT_EMPTY = -2; // empty result calculated
-const long SC_DPAGG_RESULT_VALID = -3; // valid result calculated
-const long SC_DPAGG_RESULT_ERROR = -4; // error in calculated result
+const sal_Int64 SC_DPAGG_EMPTY = 0; // empty during data collection
+const sal_Int64 SC_DPAGG_DATA_ERROR = -1; // error during data collection
+const sal_Int64 SC_DPAGG_RESULT_EMPTY = -2; // empty result calculated
+const sal_Int64 SC_DPAGG_RESULT_VALID = -3; // valid result calculated
+const sal_Int64 SC_DPAGG_RESULT_ERROR = -4; // error in calculated result
class ScDPAggData
{
private:
+ WelfordRunner maWelford;
double fVal;
double fAux;
- long nCount;
+ sal_Int64 nCount;
std::unique_ptr<ScDPAggData> pChild;
std::vector<double> mSortedValues;