From c79305f2a1218a3cbf74c7db3c9745429e8b7883 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Tue, 17 Jul 2012 13:57:43 -0400 Subject: For sum product, the initial accumulator value should be 1, not 0. Change-Id: I16ce22150627f75eab08cc4d58fc63a76572c010 --- sc/source/core/tool/scmatrix.cxx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'sc') diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx index 67f2ffb9ee93..9e358435044f 100644 --- a/sc/source/core/tool/scmatrix.cxx +++ b/sc/source/core/tool/scmatrix.cxx @@ -960,6 +960,8 @@ namespace { struct SumOp { + static const double initVal = 0.0; + void operator() (double& rAccum, double fVal) { rAccum += fVal; @@ -968,6 +970,8 @@ struct SumOp struct SumSquareOp { + static const double initVal = 0.0; + void operator() (double& rAccum, double fVal) { rAccum += fVal*fVal; @@ -976,6 +980,8 @@ struct SumSquareOp struct ProductOp { + static const double initVal = 1.0; + void operator() (double& rAccum, double fVal) { rAccum *= fVal; @@ -991,7 +997,7 @@ class WalkElementBlocks : std::unary_function aFunc(bTextAsZero); maMat.walk(aFunc); - return aFunc.getResult(); + ScMatrix::IterateResult aRes = aFunc.getResult(); + return aRes; } size_t ScMatrixImpl::Count(bool bCountStrings) const -- cgit