sc/source/core/opencl/op_math.cxx | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)
New commits: commit 353bc9db255ca802c70b15e4d5d2e2fcbcee4fe8 Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Tue Nov 27 21:40:22 2018 +0100 Commit: Luboš Luňák <l.lu...@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.lu...@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 << "}"; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits