summaryrefslogtreecommitdiff
path: root/sc/inc
diff options
context:
space:
mode:
authordante <dante19031999@gmail.com>2021-05-12 11:17:57 +0200
committerMike Kaganski <mike.kaganski@collabora.com>2021-05-13 18:37:03 +0200
commitc9de441f84ad4641662f2ce510868f3e3164a22f (patch)
treea352d322fa4721e40120eb178cea9e9d5d38d2b0 /sc/inc
parent7a578c06352328799c644e0399f14d58b05246f9 (diff)
Use double to iterate products in scmatrix.
Change-Id: If094c33d396dc5aba31b37a3042add72076f344f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115468 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sc/inc')
-rw-r--r--sc/inc/matrixoperators.hxx2
-rw-r--r--sc/inc/scmatrix.hxx21
2 files changed, 12 insertions, 11 deletions
diff --git a/sc/inc/matrixoperators.hxx b/sc/inc/matrixoperators.hxx
index 36fa1cabe3d6..813813626350 100644
--- a/sc/inc/matrixoperators.hxx
+++ b/sc/inc/matrixoperators.hxx
@@ -48,7 +48,7 @@ struct SumSquare
struct Product
{
static const double InitVal;
- void operator()(KahanSum& rAccum, double fVal) const;
+ void operator()(double& rAccum, double fVal) const;
};
}
diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index 463b15e17b42..c91253811398 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -140,29 +140,30 @@ public:
* summation algorithm,
* https://en.wikipedia.org/wiki/Kahan_summation_algorithm
*/
- struct IterateResult
+ struct IterateResultMultiple
{
double mfFirst;
double mfRest;
size_t mnCount;
- IterateResult(double fFirst, double fRest, size_t nCount) :
+ IterateResultMultiple(double fFirst, double fRest, size_t nCount) :
mfFirst(fFirst), mfRest(fRest), mnCount(nCount) {}
};
/**
- * Version of IterateResult for using Kahan sum.
+ * Iterator for executing one operation with the matrix data.
*/
- struct KahanIterateResult
+ template<typename tRes>
+ struct IterateResult
{
- KahanSum maAccumulator;
+ tRes maAccumulator;
size_t mnCount;
- KahanIterateResult(double fAccumulator, size_t nCount)
+ IterateResult(tRes fAccumulator, size_t nCount)
: maAccumulator(fAccumulator), mnCount(nCount) {}
-
- double get() const { return maAccumulator.get(); }
};
+ typedef IterateResult<KahanSum> KahanIterateResult;
+ typedef IterateResult<double> DoubleIterateResult;
/** Checks nC or nR for zero and uses GetElementsMax() whether a matrix of
@@ -378,7 +379,7 @@ public:
KahanIterateResult Sum( bool bTextAsZero, bool bIgnoreErrorValues = false ) const ;
KahanIterateResult SumSquare( bool bTextAsZero, bool bIgnoreErrorValues = false ) const ;
- KahanIterateResult Product( bool bTextAsZero, bool bIgnoreErrorValues = false ) const ;
+ DoubleIterateResult Product( bool bTextAsZero, bool bIgnoreErrorValues = false ) const ;
size_t Count(bool bCountStrings, bool bCountErrors, bool bIgnoreEmptyStrings = false) const ;
size_t MatchDoubleInColumns(double fValue, size_t nCol1, size_t nCol2) const ;
size_t MatchStringInColumns(const svl::SharedString& rStr, size_t nCol1, size_t nCol2) const ;
@@ -410,7 +411,7 @@ public:
void DivOp(bool bFlag, double fVal, const ScMatrix& rMat) ;
void PowOp(bool bFlag, double fVal, const ScMatrix& rMat) ;
- std::vector<ScMatrix::IterateResult> Collect(const std::vector<sc::op::Op>& aOp) ;
+ std::vector<ScMatrix::IterateResultMultiple> Collect(const std::vector<sc::op::Op>& aOp) ;
void ExecuteOperation(const std::pair<size_t, size_t>& rStartPos, const std::pair<size_t, size_t>& rEndPos,
DoubleOpFunction aDoubleFunc, BoolOpFunction aBoolFunc, StringOpFunction aStringFunc,