summaryrefslogtreecommitdiff
path: root/sc/source/core
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/source/core
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/source/core')
-rw-r--r--sc/source/core/tool/interpr5.cxx2
-rw-r--r--sc/source/core/tool/interpr6.cxx4
-rw-r--r--sc/source/core/tool/matrixoperators.cxx2
-rw-r--r--sc/source/core/tool/scmatrix.cxx34
4 files changed, 21 insertions, 21 deletions
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index 613c467cbdc2..1e16518ae8da 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -1853,7 +1853,7 @@ void ScInterpreter::ScSumXMY2()
}
else
{
- PushDouble(pResMat->SumSquare(false).get());
+ PushDouble(pResMat->SumSquare(false).maAccumulator.get());
}
}
diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index 0e2824ef1f2e..1c7ed73d5c93 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -403,8 +403,8 @@ static void IterateMatrix(
break;
case ifPRODUCT:
{
- ScMatrix::KahanIterateResult aRes = pMat->Product(bTextAsZero, bIgnoreErrVal);
- fRes *= aRes.get();
+ ScMatrix::DoubleIterateResult aRes = pMat->Product(bTextAsZero, bIgnoreErrVal);
+ fRes *= aRes.maAccumulator;
rCount += aRes.mnCount;
}
break;
diff --git a/sc/source/core/tool/matrixoperators.cxx b/sc/source/core/tool/matrixoperators.cxx
index e65d4d7c0dc2..780f789ed94f 100644
--- a/sc/source/core/tool/matrixoperators.cxx
+++ b/sc/source/core/tool/matrixoperators.cxx
@@ -19,7 +19,7 @@ void SumSquare::operator()(KahanSum& rAccum, double fVal) const { rAccum += fVal
const double SumSquare::InitVal = 0.0;
-void Product::operator()(KahanSum& rAccum, double fVal) const { rAccum *= fVal; }
+void Product::operator()(double& rAccum, double fVal) const { rAccum *= fVal; }
const double Product::InitVal = 1.0;
}
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index a10863ea3a53..d3c8667c66c1 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -304,7 +304,7 @@ public:
ScMatrix::KahanIterateResult Sum( bool bTextAsZero, bool bIgnoreErrorValues ) const;
ScMatrix::KahanIterateResult SumSquare( bool bTextAsZero, bool bIgnoreErrorValues ) const;
- ScMatrix::KahanIterateResult Product( bool bTextAsZero, bool bIgnoreErrorValues ) const;
+ ScMatrix::DoubleIterateResult Product( bool bTextAsZero, bool bIgnoreErrorValues ) const;
size_t Count(bool bCountStrings, bool bCountErrors, bool bIgnoreEmptyStrings) 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;
@@ -328,7 +328,7 @@ public:
const ScMatrix::EmptyOpFunction& aEmptyFunc) const;
template<typename T>
- std::vector<ScMatrix::IterateResult> ApplyCollectOperation(const std::vector<T>& aOp);
+ std::vector<ScMatrix::IterateResultMultiple> ApplyCollectOperation(const std::vector<T>& aOp);
void MatConcat(SCSIZE nMaxCol, SCSIZE nMaxRow, const ScMatrixRef& xMat1, const ScMatrixRef& xMat2,
SvNumberFormatter& rFormatter, svl::SharedStringPool& rPool);
@@ -1107,11 +1107,11 @@ double ScMatrixImpl::Xor() const
namespace {
-template<typename Op>
+template<typename Op, typename tRes>
class WalkElementBlocks
{
Op maOp;
- ScMatrix::KahanIterateResult maRes;
+ ScMatrix::IterateResult<tRes> maRes;
bool mbTextAsZero:1;
bool mbIgnoreErrorValues:1;
public:
@@ -1120,7 +1120,7 @@ public:
mbTextAsZero(bTextAsZero), mbIgnoreErrorValues(bIgnoreErrorValues)
{}
- const ScMatrix::KahanIterateResult& getResult() const { return maRes; }
+ const ScMatrix::IterateResult<tRes>& getResult() const { return maRes; }
void operator() (const MatrixImplType::element_block_node_type& node)
{
@@ -1173,7 +1173,7 @@ template<typename Op>
class WalkElementBlocksMultipleValues
{
const std::vector<Op>* mpOp;
- std::vector<ScMatrix::IterateResult> maRes;
+ std::vector<ScMatrix::IterateResultMultiple> maRes;
bool mbFirst:1;
public:
WalkElementBlocksMultipleValues(const std::vector<Op>& aOp) :
@@ -1200,7 +1200,7 @@ public:
return *this;
}
- const std::vector<ScMatrix::IterateResult>& getResult() const { return maRes; }
+ const std::vector<ScMatrix::IterateResultMultiple>& getResult() const { return maRes; }
void operator() (const MatrixImplType::element_block_node_type& node)
{
@@ -2080,10 +2080,10 @@ public:
namespace {
-template<typename TOp>
-ScMatrix::KahanIterateResult GetValueWithCount(bool bTextAsZero, bool bIgnoreErrorValues, const MatrixImplType& maMat)
+template<typename TOp, typename tRes>
+ScMatrix::IterateResult<tRes> GetValueWithCount(bool bTextAsZero, bool bIgnoreErrorValues, const MatrixImplType& maMat)
{
- WalkElementBlocks<TOp> aFunc(bTextAsZero, bIgnoreErrorValues);
+ WalkElementBlocks<TOp, tRes> aFunc(bTextAsZero, bIgnoreErrorValues);
aFunc = maMat.walk(aFunc);
return aFunc.getResult();
}
@@ -2092,17 +2092,17 @@ ScMatrix::KahanIterateResult GetValueWithCount(bool bTextAsZero, bool bIgnoreErr
ScMatrix::KahanIterateResult ScMatrixImpl::Sum(bool bTextAsZero, bool bIgnoreErrorValues) const
{
- return GetValueWithCount<sc::op::Sum>(bTextAsZero, bIgnoreErrorValues, maMat);
+ return GetValueWithCount<sc::op::Sum, KahanSum>(bTextAsZero, bIgnoreErrorValues, maMat);
}
ScMatrix::KahanIterateResult ScMatrixImpl::SumSquare(bool bTextAsZero, bool bIgnoreErrorValues) const
{
- return GetValueWithCount<sc::op::SumSquare>(bTextAsZero, bIgnoreErrorValues, maMat);
+ return GetValueWithCount<sc::op::SumSquare, KahanSum>(bTextAsZero, bIgnoreErrorValues, maMat);
}
-ScMatrix::KahanIterateResult ScMatrixImpl::Product(bool bTextAsZero, bool bIgnoreErrorValues) const
+ScMatrix::DoubleIterateResult ScMatrixImpl::Product(bool bTextAsZero, bool bIgnoreErrorValues) const
{
- return GetValueWithCount<sc::op::Product>(bTextAsZero, bIgnoreErrorValues, maMat);
+ return GetValueWithCount<sc::op::Product, double>(bTextAsZero, bIgnoreErrorValues, maMat);
}
size_t ScMatrixImpl::Count(bool bCountStrings, bool bCountErrors, bool bIgnoreEmptyStrings) const
@@ -2423,7 +2423,7 @@ void ScMatrixImpl::ApplyOperation(T aOp, ScMatrixImpl& rMat)
}
template<typename T>
-std::vector<ScMatrix::IterateResult> ScMatrixImpl::ApplyCollectOperation(const std::vector<T>& aOp)
+std::vector<ScMatrix::IterateResultMultiple> ScMatrixImpl::ApplyCollectOperation(const std::vector<T>& aOp)
{
WalkElementBlocksMultipleValues<T> aFunc(aOp);
aFunc = maMat.walk(std::move(aFunc));
@@ -3218,7 +3218,7 @@ ScMatrix::KahanIterateResult ScMatrix::SumSquare(bool bTextAsZero, bool bIgnoreE
return pImpl->SumSquare(bTextAsZero, bIgnoreErrorValues);
}
-ScMatrix::KahanIterateResult ScMatrix::Product(bool bTextAsZero, bool bIgnoreErrorValues) const
+ScMatrix::DoubleIterateResult ScMatrix::Product(bool bTextAsZero, bool bIgnoreErrorValues) const
{
return pImpl->Product(bTextAsZero, bIgnoreErrorValues);
}
@@ -3425,7 +3425,7 @@ void ScMatrix::ExecuteOperation(const std::pair<size_t, size_t>& rStartPos,
pImpl->ExecuteOperation(rStartPos, rEndPos, aDoubleFunc, aBoolFunc, aStringFunc, aEmptyFunc);
}
-std::vector<ScMatrix::IterateResult> ScMatrix::Collect(const std::vector<sc::op::Op>& aOp)
+std::vector<ScMatrix::IterateResultMultiple> ScMatrix::Collect(const std::vector<sc::op::Op>& aOp)
{
return pImpl->ApplyCollectOperation(aOp);
}