[Libreoffice-commits] core.git: sc/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Dec 3 14:30:40 UTC 2018
sc/source/core/opencl/op_math.cxx | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
New commits:
commit 353bc9db255ca802c70b15e4d5d2e2fcbcee4fe8
Author: Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Tue Nov 27 21:40:22 2018 +0100
Commit: Luboš Luňák <l.lunak at collabora.com>
CommitDate: Mon Dec 3 15:30:16 2018 +0100
fix OpenCL PRODUCT when there are actually no values
PRODUCT() when there are no arguments (or all cells are empty) is 0.
Change-Id: I4bcb9afe84d08833526255da0c61f6847d68ea36
Reviewed-on: https://gerrit.libreoffice.org/64232
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak at collabora.com>
diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx
index 040c0afc4a55..45306aee893e 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -2711,7 +2711,8 @@ void OpProduct::GenSlidingWindowFunction(std::stringstream &ss,
ss << ") {\n";
ss << " int gid0 = get_global_id(0);\n";
ss << " int i = 0;\n";
- ss << " double product=1.0;\n\n";
+ ss << " double product=1.0;\n";
+ ss << " int count = 0;\n\n";
for (DynamicKernelArgumentRef & rArg : vSubArguments)
{
FormulaToken *pCur = rArg->GetFormulaToken();
@@ -2747,25 +2748,35 @@ void OpProduct::GenSlidingWindowFunction(std::stringstream &ss,
ss << "0; i < " << pDVR->GetArrayLength() << "; i++)\n";
ss << " {\n";
}
- ss << "if(!isnan("<<rArg->GenSlidingWindowDeclRef()<<"))\n";
- ss << "product = product*";
+ ss << " if(!isnan("<<rArg->GenSlidingWindowDeclRef()<<"))\n";
+ ss << " {\n";
+ ss << " product = product*";
ss << rArg->GenSlidingWindowDeclRef()<<";\n";
+ ss << " ++count;\n";
+ ss << " }\n";
ss << " }\n";
}
else if (pCur->GetType() == formula::svSingleVectorRef)
{
- ss << "if(!isnan("<<rArg->GenSlidingWindowDeclRef()<<"))\n";
- ss << "product = product*";
+ ss << " if(!isnan("<<rArg->GenSlidingWindowDeclRef()<<"))\n";
+ ss << " {\n";
+ ss << " product = product*";
ss << rArg->GenSlidingWindowDeclRef()<<";\n";
-
+ ss << " ++count;\n";
+ ss << " }\n";
}
else
{
- ss << "if(!isnan("<<rArg->GenSlidingWindowDeclRef()<<"))\n";
- ss << "product = product*";
+ ss << " if(!isnan("<<rArg->GenSlidingWindowDeclRef()<<"))\n";
+ ss << " {\n";
+ ss << " product = product*";
ss << rArg->GenSlidingWindowDeclRef()<<";\n";
+ ss << " ++count;\n";
+ ss << " }\n";
}
}
+ ss << " if(count == 0)\n";
+ ss << " return 0;\n";
ss << " return product;\n";
ss << "}";
}
More information about the Libreoffice-commits
mailing list