summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-09-20 18:08:39 +0200
committerLuboš Luňák <l.lunak@collabora.com>2022-09-21 10:24:15 +0200
commitb764e5e0532a9c017f871b60026e507f283eb133 (patch)
tree212c3b6c7ce5e7aa9c7a25024068d8149fd17fbc /sc/source
parentebc0db7acee7a470c4e41cddbb97274343899ce0 (diff)
fix opencl WEIBULL and ZTEST functions
Sync them with their core versions. Change-Id: I8890b13c0be8ac1da91132ec7e294f542dcc577e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140256 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/opencl/op_statistical.cxx23
1 files changed, 15 insertions, 8 deletions
diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx
index 6441f8343daa..598f81df9d83 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -50,10 +50,19 @@ void OpZTest::GenSlidingWindowFunction(outputstream &ss,
ss << " mue = fSum / fCount;\n";
GenerateArg( "mu", 1, vSubArguments, ss );
if(vSubArguments.size() == 3)
+ {
GenerateArg( "sigma", 2, vSubArguments, ss );
+ ss << " if(sigma <= 0.0)\n";
+ ss << " return CreateDoubleError(IllegalArgument);\n";
+ ss << " return 0.5 - gauss((mue-mu)*sqrt(fCount)/sigma);\n";
+ }
else
+ {
ss << " double sigma = (fSumSqr-fSum*fSum/fCount)/(fCount-1.0);\n";
- ss << " return 0.5 - gauss((mue-mu)/sqrt(sigma/fCount));\n";
+ ss << " if(sigma == 0.0)\n";
+ ss << " return CreateDoubleError(DivisionByZero);\n";
+ ss << " return 0.5 - gauss((mue-mu)/sqrt(sigma/fCount));\n";
+ }
ss << "}\n";
}
@@ -309,15 +318,13 @@ void OpWeibull::GenSlidingWindowFunction(outputstream &ss,
GenerateArg( "alpha", 1, vSubArguments, ss );
GenerateArg( "beta", 2, vSubArguments, ss );
GenerateArg( "kum", 3, vSubArguments, ss );
- ss << " if(alpha <= 0.0 || beta <=0.0 || kum < 0.0)\n";
+ ss << " if(alpha <= 0.0 || beta <=0.0 || x < 0.0)\n";
ss << " return CreateDoubleError(IllegalArgument);\n";
- ss << " else if(kum == 0.0)\n";
- ss << " {\n";
- ss << " return alpha*pow(pow(beta,alpha),-1.0)*pow(x,alpha-1.0)";
- ss << "*exp(-pow(x*pow(beta,-1.0),alpha));\n";
- ss << " }\n";
+ ss << " if (kum == 0.0)\n";
+ ss << " return alpha/pow(beta,alpha)*pow(x,alpha-1.0)*\n";
+ ss << " exp(-pow(x/beta,alpha));\n";
ss << " else\n";
- ss << " return 1.0-exp(-pow(x*pow(beta,-1.0),alpha));\n";
+ ss << " return 1.0 - exp(-pow(x/beta,alpha));\n";
ss << "}\n";
}