[Libreoffice-commits] core.git: 3 commits - officecfg/registry sc/source
Tor Lillqvist
tml at collabora.com
Wed Nov 19 08:56:19 PST 2014
officecfg/registry/schema/org/openoffice/Office/Calc.xcs | 2 -
sc/source/core/tool/calcconfig.cxx | 7 +++
sc/source/ui/optdlg/calcoptionsdlg.cxx | 29 +++++++++++----
3 files changed, 31 insertions(+), 7 deletions(-)
New commits:
commit c560b4d7d981328026bec2b0a6e6ea533c02818c
Author: Tor Lillqvist <tml at collabora.com>
Date: Wed Nov 19 18:49:49 2014 +0200
Add COUNT
Change-Id: Ibdff629c3653d43e08b5200a7babb7ff05a7b5ac
diff --git a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
index bfb5f88..aa44d84 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
@@ -1373,7 +1373,7 @@
might be calculated using OpenCL.</desc>
<!-- numeric values correspond to RAND;SIN;COS;TAN;ATAN;EXP;LN;SQRT;NORMSINV;ROUND;POWER;SUBPRODUCT;PROUDCT;NORMDIST;MIN;MAX;SUM;AVERAGE;SUMIFS -->
</info>
- <value>40;41;42;43;82;83;84;88;102;103;104;149;204;209;213;222;223;224;225;226;236;403</value>
+ <value>40;41;42;43;82;83;84;88;102;103;104;149;204;209;213;222;223;224;225;226;227;236;403</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 0ec1e17..69abb2d 100644
--- a/sc/source/core/tool/calcconfig.cxx
+++ b/sc/source/core/tool/calcconfig.cxx
@@ -62,6 +62,7 @@ void ScCalcConfig::setOpenCLConfigToDefault()
maOpenCLSubsetOpCodes.insert(ocSum);
maOpenCLSubsetOpCodes.insert(ocProduct);
maOpenCLSubsetOpCodes.insert(ocAverage);
+ maOpenCLSubsetOpCodes.insert(ocCount);
maOpenCLSubsetOpCodes.insert(ocNormDist);
maOpenCLSubsetOpCodes.insert(ocSumIfs);
commit 44f941692521c21f5c152f3bab84b07f19f22353
Author: Tor Lillqvist <tml at collabora.com>
Date: Wed Nov 19 18:48:14 2014 +0200
Add opcodes for binary operators + - * /
These are of course very common, and one would hope they are correctly
implemented in our OpenCL code.
Change-Id: I0ca6d3983502b18a1ea56522d4f20673ad94357d
diff --git a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
index abf01b0..bfb5f88 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
@@ -1373,7 +1373,7 @@
might be calculated using OpenCL.</desc>
<!-- numeric values correspond to RAND;SIN;COS;TAN;ATAN;EXP;LN;SQRT;NORMSINV;ROUND;POWER;SUBPRODUCT;PROUDCT;NORMDIST;MIN;MAX;SUM;AVERAGE;SUMIFS -->
</info>
- <value>82;83;84;88;102;103;104;149;204;209;213;222;223;224;225;226;236;403</value>
+ <value>40;41;42;43;82;83;84;88;102;103;104;149;204;209;213;222;223;224;225;226;236;403</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 ff81e98..0ec1e17 100644
--- a/sc/source/core/tool/calcconfig.cxx
+++ b/sc/source/core/tool/calcconfig.cxx
@@ -40,6 +40,12 @@ void ScCalcConfig::setOpenCLConfigToDefault()
mbOpenCLAutoSelect = true;
mnOpenCLMinimumFormulaGroupSize = 100;
+ // Keep in order of opcode value, is that clearest? (Random order,
+ // at least, would make no sense at all.)
+ maOpenCLSubsetOpCodes.insert(ocAdd);
+ maOpenCLSubsetOpCodes.insert(ocSub);
+ maOpenCLSubsetOpCodes.insert(ocMul);
+ maOpenCLSubsetOpCodes.insert(ocDiv);
maOpenCLSubsetOpCodes.insert(ocSin);
maOpenCLSubsetOpCodes.insert(ocCos);
maOpenCLSubsetOpCodes.insert(ocTan);
commit f8e17ff09f03240a71b1292b9bd8af9a17c10ca7
Author: Tor Lillqvist <tml at collabora.com>
Date: Wed Nov 19 16:27:33 2014 +0200
Test also MIN, MAX and PRODUCT
Change-Id: Ibbc4c65271142b63c85d08ab4c9162ba96d32b6a
diff --git a/sc/source/ui/optdlg/calcoptionsdlg.cxx b/sc/source/ui/optdlg/calcoptionsdlg.cxx
index 92af35a..a92b75d 100644
--- a/sc/source/ui/optdlg/calcoptionsdlg.cxx
+++ b/sc/source/ui/optdlg/calcoptionsdlg.cxx
@@ -9,6 +9,7 @@
#include <sal/config.h>
+#include <algorithm>
#include <cmath>
#include "calcconfig.hxx"
@@ -999,27 +1000,43 @@ IMPL_LINK( ScCalcOptionsDialog, TestClickHdl, PushButton*, )
pDoc->SetValue(ScAddress(0,i,1), (i%13)/13.);
#endif
pDoc->SetValue(ScAddress(1,i,1), comphelper::rng::uniform_real_distribution(0, 1000));
+ // The [0.1,2.5) interval is carefully chosen to keep the product of them likely "sane"
+ pDoc->SetValue(ScAddress(6,i,1), comphelper::rng::uniform_real_distribution(0.1, 2.5));
pDoc->SetString(ScAddress(10,i,1), OUString("=IF(AND(A") + OUString::number(i+1) + ">= 0,A" + OUString::number(i+1) + "<= 1),0,1)");
}
pDoc->SetString(ScAddress(0,1,0), OUString("=SUM(RAND.K1:RAND.K") + sN + ")");
- for (int i = 0; i < N/10; ++i)
+ for (int i = 0; i < N/3; ++i)
{
pDoc->SetString(ScAddress(2,i,1), OUString("=SUM(B") + OUString::number(i+1) + ":B" + OUString::number(i+N/2) + ")");
pDoc->SetString(ScAddress(3,i,1), OUString("=AVERAGE(B") + OUString::number(i+1) + ":B" + OUString::number(i+N/2) + ")");
+ pDoc->SetString(ScAddress(4,i,1), OUString("=MIN(B") + OUString::number(i+1) + ":B" + OUString::number(i+N/2) + ")");
+ pDoc->SetString(ScAddress(5,i,1), OUString("=MAX(B") + OUString::number(i+1) + ":B" + OUString::number(i+N/2) + ")");
+ pDoc->SetString(ScAddress(7,i,1), OUString("=PRODUCT(G") + OUString::number(i+1) + ":G" + OUString::number(i+N/2) + ")");
- double sum(0);
+ double nSum(0), nMin(DBL_MAX), nMax(-DBL_MAX), nProduct(1);
for (int j = 0; j < N/2; ++j)
- sum += pDoc->GetValue(ScAddress(1,i+j,1));
+ {
+ nSum += pDoc->GetValue(ScAddress(1,i+j,1));
+ nMin = std::min(nMin, pDoc->GetValue(ScAddress(1,i+j,1)));
+ nMax = std::max(nMax, pDoc->GetValue(ScAddress(1,i+j,1)));
+ nProduct *= pDoc->GetValue(ScAddress(6,i+j,1));
+ }
pDoc->SetString(ScAddress(12,i,1),
- OUString("=IF(C") + OUString::number(i+1) + "-" + OUString::number(sum) + "<" + sEpsilon + ",0,1");
+ OUString("=IF(C") + OUString::number(i+1) + "-" + OUString::number(nSum) + "<" + sEpsilon + ",0,1");
pDoc->SetString(ScAddress(13,i,1),
- OUString("=IF(D") + OUString::number(i+1) + "-" + OUString::number(sum/(N/2)) + "<" + sEpsilon + ",0,1");
+ OUString("=IF(D") + OUString::number(i+1) + "-" + OUString::number(nSum/(N/2)) + "<" + sEpsilon + ",0,1");
+ pDoc->SetString(ScAddress(14,i,1),
+ OUString("=IF(E") + OUString::number(i+1) + "-" + OUString::number(nMin) + "<" + sEpsilon + ",0,1");
+ pDoc->SetString(ScAddress(15,i,1),
+ OUString("=IF(F") + OUString::number(i+1) + "-" + OUString::number(nMax) + "<" + sEpsilon + ",0,1");
+ pDoc->SetString(ScAddress(16,i,1),
+ OUString("=IF((H") + OUString::number(i+1) + "-" + OUString::number(nProduct) + ")/H" + OUString::number(i+1) + "<" + sEpsilon + ",0,1");
}
- pDoc->SetString(ScAddress(0,2,0), OUString("=SUM(RAND.M1:RAND.N") + OUString::number(N/10) + ")");
+ pDoc->SetString(ScAddress(0,2,0), OUString("=SUM(RAND.M1:RAND.Q") + OUString::number(N/3) + ")");
// MISCMATH sheet
pDoc->InsertTab(2, "MISCMATH");
More information about the Libreoffice-commits
mailing list