[Libreoffice-commits] core.git: 4 commits - formula/source officecfg/registry sc/source
Tor Lillqvist
tml at collabora.com
Fri Mar 6 01:42:29 PST 2015
formula/source/core/api/vectortoken.cxx | 10 ++++++++--
officecfg/registry/schema/org/openoffice/Office/Calc.xcs | 2 +-
sc/source/core/data/grouptokenconverter.cxx | 12 ++++++++++++
sc/source/core/opencl/op_statistical.cxx | 2 +-
sc/source/core/tool/calcconfig.cxx | 5 +++++
5 files changed, 27 insertions(+), 4 deletions(-)
New commits:
commit 4cd7b4ab8aeaf61f5e30e4b63e039b7bb9519e85
Author: Tor Lillqvist <tml at collabora.com>
Date: Fri Mar 6 11:31:18 2015 +0200
Set #DIV/0! error in VAR() OpenCL implementation when appropriate
Returning DBL_MAX doesn't make sense. The traditional C++ implementation and
other spreadsheet products return an error.
Change-Id: I8189c3ecf4aa7b1df00ec2fd8b91030085848bf4
diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx
index d47c446..e6fb8e6 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -194,7 +194,7 @@ void OpVar::GenSlidingWindowFunction(std::stringstream &ss,
}
}
ss << " if (fCount <= 1.0)\n";
- ss << " return DBL_MAX;\n";
+ ss << " return CreateDoubleError(errDivisionByZero);\n";
ss << " else\n";
ss << " return vSum * pow(fCount - 1.0,-1.0);\n";
ss << "}\n";
commit fa4ce83f567cfb735bdfd2319458585ded4cd554
Author: Tor Lillqvist <tml at collabora.com>
Date: Fri Mar 6 11:21:02 2015 +0200
Don't return negative values from ScGroupTokenConverter::trimLength()
Surely it doesn't make sense, but we should return zero instead?
At the two call sites, there are tests against a zero having been returned,
but not against a negative value. And the return value is even passed as the
nArrayLength parameter to a formula::DoubleVectorRefToken constructor, which
is of type size_t, thus unsigned. Passing for instance -4 to it ends up being
interpreted as 18446744073709551612, which has fun consequences.
Change-Id: Ifca97cd4bae8e921345bcf9d0ca6bb040e3c3b79
diff --git a/sc/source/core/data/grouptokenconverter.cxx b/sc/source/core/data/grouptokenconverter.cxx
index bfb6de3..da3964c 100644
--- a/sc/source/core/data/grouptokenconverter.cxx
+++ b/sc/source/core/data/grouptokenconverter.cxx
@@ -63,7 +63,19 @@ SCROW ScGroupTokenConverter::trimLength(SCTAB nTab, SCCOL nCol1, SCCOL nCol2, SC
SCROW nLastRow = nRow + nRowLen - 1; // current last row.
nLastRow = mrDoc.GetLastDataRow(nTab, nCol1, nCol2, nLastRow);
if (nLastRow < (nRow + nRowLen - 1))
+ {
+ // This can end up negative! Was that the original intent, or
+ // is it accidental? Was it not like that originally but the
+ // surrounding conditions changed?
nRowLen = nLastRow - nRow + 1;
+ // Anyway, let's assume it doesn't make sense to return a
+ // negative value here. But should we then return 0 or 1? In
+ // the "Column is empty" case below, we return 1, why!? And,
+ // at the callsites there are tests for a zero value returned
+ // from this function (but not for a negative one).
+ if (nRowLen < 0)
+ nRowLen = 0;
+ }
else if (nLastRow == 0)
// Column is empty.
nRowLen = 1;
commit abbd86925dab2621f38c85d8be8772ca56f037f6
Author: Tor Lillqvist <tml at collabora.com>
Date: Fri Mar 6 11:35:11 2015 +0200
Add a few SAL_INFOs
Change-Id: I252987d6c5e5da56a83742c96b4e86abbb7108c6
diff --git a/formula/source/core/api/vectortoken.cxx b/formula/source/core/api/vectortoken.cxx
index b0077aa..99f7dec 100644
--- a/formula/source/core/api/vectortoken.cxx
+++ b/formula/source/core/api/vectortoken.cxx
@@ -42,7 +42,10 @@ bool VectorRefArray::isValid() const
}
SingleVectorRefToken::SingleVectorRefToken( const VectorRefArray& rArray, size_t nReqLength, size_t nArrayLength ) :
- FormulaToken(svSingleVectorRef, ocPush), maArray(rArray), mnRequestedLength(nReqLength), mnArrayLength(nArrayLength) {}
+ FormulaToken(svSingleVectorRef, ocPush), maArray(rArray), mnRequestedLength(nReqLength), mnArrayLength(nArrayLength)
+{
+ SAL_INFO("formula.core", "Created SingleVectorRefToken nReqLength=" << nReqLength << " nArrayLength=" << nArrayLength);
+}
FormulaToken* SingleVectorRefToken::Clone() const
{
@@ -64,7 +67,10 @@ DoubleVectorRefToken::DoubleVectorRefToken(
size_t nRefRowSize, bool bStartFixed, bool bEndFixed ) :
FormulaToken(svDoubleVectorRef, ocPush),
maArrays(rArrays), mnRequestedLength(nReqLength), mnArrayLength(nArrayLength),
- mnRefRowSize(nRefRowSize), mbStartFixed(bStartFixed), mbEndFixed(bEndFixed) {}
+ mnRefRowSize(nRefRowSize), mbStartFixed(bStartFixed), mbEndFixed(bEndFixed)
+{
+ SAL_INFO("formula.core", "Created DoubleVectorRefToken nReqLength=" << nReqLength << " nArrayLength=" << nArrayLength);
+}
FormulaToken* DoubleVectorRefToken::Clone() const
{
commit 0ab2973f84234dccf9cc22ffd179039065e97df0
Author: Tor Lillqvist <tml at collabora.com>
Date: Thu Mar 5 18:03:27 2015 +0200
Add VAR, CORREL, COVAR, PEARSON and SLOPE to the OpenCL default opcode subset
Having these statistical functions perform well is essential in many cases,
and their implementations seem to be correct.
Change-Id: I30afa096295cc163f8c0146e916a77aa411dd07b
diff --git a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
index 5966b0b..679e868 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
@@ -1373,7 +1373,7 @@
true, and a formula contains only these operators and
functions, it might be calculated using OpenCL.</desc>
</info>
- <value>+;-;*;/;RAND;SIN;COS;TAN;ATAN;EXP;LN;SQRT;NORMSINV;ROUND;POWER;SUMPRODUCT;MIN;MAX;SUM;PRODUCT;AVERAGE;COUNT;NORMDIST;SUMIFS</value>
+ <value>+;-;*;/;RAND;SIN;COS;TAN;ATAN;EXP;LN;SQRT;NORMSINV;ROUND;POWER;SUMPRODUCT;MIN;MAX;SUM;PRODUCT;AVERAGE;COUNT;VAR;NORMDIST;CORREL;COVAR;PEARSON;SLOPE;SUMIFS</value>
</prop>
<prop oor:name="OpenCLAutoSelect" oor:type="xs:boolean" oor:nillable="false">
<!-- UIHints: Tools - Options Spreadsheet Formula -->
diff --git a/sc/source/core/tool/calcconfig.cxx b/sc/source/core/tool/calcconfig.cxx
index f152408..7a108f5 100644
--- a/sc/source/core/tool/calcconfig.cxx
+++ b/sc/source/core/tool/calcconfig.cxx
@@ -63,7 +63,12 @@ void ScCalcConfig::setOpenCLConfigToDefault()
maOpenCLSubsetOpCodes.insert(ocProduct);
maOpenCLSubsetOpCodes.insert(ocAverage);
maOpenCLSubsetOpCodes.insert(ocCount);
+ maOpenCLSubsetOpCodes.insert(ocVar);
maOpenCLSubsetOpCodes.insert(ocNormDist);
+ maOpenCLSubsetOpCodes.insert(ocCorrel);
+ maOpenCLSubsetOpCodes.insert(ocCovar);
+ maOpenCLSubsetOpCodes.insert(ocPearson);
+ maOpenCLSubsetOpCodes.insert(ocSlope);
maOpenCLSubsetOpCodes.insert(ocSumIfs);
}
More information about the Libreoffice-commits
mailing list