summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-09-01 13:59:43 +0200
committerLuboš Luňák <l.lunak@collabora.com>2022-09-06 12:03:18 +0200
commit65a082168ef5c2ff002f20a615b622816c3f4d3a (patch)
tree7e0ee75d552b94593035145db6edbfc72b65b6c6 /sc
parent218b288d0ca32e4372f546b143fa71542f75dcd0 (diff)
use opencl's built-in PI values instead of hardcoded ones
Fixes a sc_subsequent_filters_test error because of =ACOT(-1)/PI() getting slightly miscalculated. Change-Id: I3846553cae55f463c34fba13663cad72c0e60b34 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139195 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/opencl/formulagroupcl.cxx2
-rw-r--r--sc/source/core/opencl/op_addin.cxx7
-rw-r--r--sc/source/core/opencl/op_math.cxx5
-rw-r--r--sc/source/core/opencl/op_statistical.cxx7
-rw-r--r--sc/source/core/opencl/opinlinefun_statistical.cxx1
5 files changed, 8 insertions, 14 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 8d959cc42dbe..9838e9adaef2 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -474,7 +474,7 @@ public:
}
virtual void GenDeclRef( outputstream& ss ) const override
{
- ss << "3.14159265358979";
+ ss << "M_PI";
}
virtual void GenSlidingWindowDecl( outputstream& ss ) const override
{
diff --git a/sc/source/core/opencl/op_addin.cxx b/sc/source/core/opencl/op_addin.cxx
index 78a98a9bf9db..5e4dc04a2b0b 100644
--- a/sc/source/core/opencl/op_addin.cxx
+++ b/sc/source/core/opencl/op_addin.cxx
@@ -93,10 +93,7 @@ void OpBesselj::GenSlidingWindowFunction(outputstream &ss,
ss << " N = ";
ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
}
- ss << " double f_PI = 3.1415926535897932385;\n";
- ss << " double f_2_DIV_PI = 2.0 / f_PI;\n";
- ss << " double f_PI_DIV_2 = f_PI / 2.0;\n";
- ss << " double f_PI_DIV_4 = f_PI / 4.0;\n";
+ ss << " double f_2_DIV_PI = 2.0 / M_PI;\n";
ss << " if( N < 0.0 )\n";
ss << " return CreateDoubleError(IllegalArgument);\n";
ss << " if (x == 0.0)\n";
@@ -110,7 +107,7 @@ void OpBesselj::GenSlidingWindowFunction(outputstream &ss,
ss << " {\n";
ss << " if (bAsymptoticPossible)\n";
ss << " return fSign * sqrt(f_2_DIV_PI/fX)";
- ss << "* cos(fX-N*f_PI_DIV_2-f_PI_DIV_4);\n";
+ ss << "* cos(fX-N*M_PI_2-M_PI_4);\n";
ss << " else\n";
ss << " return CreateDoubleError(NoConvergence);\n";
ss << " }\n";
diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx
index 744c360a75bc..7cb632050aa4 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1791,7 +1791,7 @@ void OpRadians::GenSlidingWindowFunction(outputstream &ss,
ss << " double tmp;\n";
GenTmpVariables(ss,vSubArguments);
CheckAllSubArgumentIsNan(ss,vSubArguments);
- ss << " tmp = tmp0 * 3.14159265358979 / 180.0;\n";
+ ss << " tmp = tmp0 * M_PI / 180.0;\n";
ss << " return tmp;\n";
ss << "}";
}
@@ -2519,8 +2519,7 @@ void OpSqrtPi::GenSlidingWindowFunction(outputstream &ss,
ss << vSubArguments[0]->GenSlidingWindowDeclRef();
ss << ";\n";
}
- ss << " return (double)sqrt(arg0 *";
- ss << " 3.1415926535897932);\n";
+ ss << " return (double)sqrt(arg0 * M_PI);\n";
ss << "}";
}
void OpCeil::GenSlidingWindowFunction(outputstream &ss,
diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx
index 5acd3c2508fc..bad9626a0717 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -5915,7 +5915,7 @@ void OpChiSqDist::BinInlineFun(std::set<std::string>& decls,
decls.insert(fMaxGammaArgumentDecl);decls.insert(GetChiSqDistCDFDecl);
decls.insert(GetChiSqDistPDFDecl);decls.insert(GetLowRegIGammaDecl);
decls.insert(GetGammaContFractionDecl);decls.insert(GetGammaSeriesDecl);
- decls.insert(fHalfMachEpsDecl);decls.insert(F_PIDecl);
+ decls.insert(fHalfMachEpsDecl);
decls.insert(fBigInvDecl);
funs.insert(GetGammaContFraction);funs.insert(GetChiSqDistCDF);
@@ -6005,7 +6005,7 @@ vSubArguments)
decls.insert(fMaxGammaArgumentDecl);decls.insert(GetChiSqDistCDFDecl);
decls.insert(GetLowRegIGammaDecl);decls.insert(lcl_IterateInverseChiSQInvDecl);
decls.insert(GetGammaContFractionDecl);decls.insert(GetGammaSeriesDecl);
- decls.insert(fHalfMachEpsDecl);decls.insert(F_PIDecl);
+ decls.insert(fHalfMachEpsDecl);
decls.insert(fBigInvDecl);decls.insert(lcl_HasChangeOfSignDecl);
decls.insert(fMachEpsDecl);
@@ -7603,7 +7603,6 @@ void OpHypGeomDist::GenSlidingWindowFunction(outputstream &ss,
" double n1=floor(arg1);\n"
" double x1=floor(arg0);\n"
" double num[9];\n"
- " double PI = 3.1415926535897932384626433832795;\n"
" double tmp;\n"
" if( (x1 < 0.0) || (n1 < x1) || (M1 < x1) || (N1 < n1) ||"
"(N1 < M1) || (x1 < n1 - N1 + M1) )\n"
@@ -7630,7 +7629,7 @@ void OpHypGeomDist::GenSlidingWindowFunction(outputstream &ss,
" num[i]=log(tgamma(num[i])*num[i]);\n"
" }\n"
" else\n"
- " num[i]=0.5*log(2.0*PI)+(num[i]+0.5)*log(num[i])-num[i]+"
+ " num[i]=0.5*log(2.0*M_PI)+(num[i]+0.5)*log(num[i])-num[i]+"
"(1.0/(12.0*num[i])-1.0/(360*pow(num[i],3)));\n"
" }\n";
ss << " tmp=pow(M_E,(num[0]+num[3]+num[7]+num[8]";
diff --git a/sc/source/core/opencl/opinlinefun_statistical.cxx b/sc/source/core/opencl/opinlinefun_statistical.cxx
index 2609fb0ca3bc..4247e8f2ec32 100644
--- a/sc/source/core/opencl/opinlinefun_statistical.cxx
+++ b/sc/source/core/opencl/opinlinefun_statistical.cxx
@@ -10,7 +10,6 @@
#ifndef SC_OPENCL_OPINLINFUN_statistical
#define SC_OPENCL_OPINLINFUN_statistical
std::string MinDecl = "#define Min 2.22507e-308\n";
-std::string F_PIDecl="#define M_PI 3.1415926535897932384626433832795\n";
std::string fBigInvDecl ="#define fBigInv 2.22045e-016\n";
std::string fMachEpsDecl ="#define fMachEps 2.22045e-016\n";
std::string fLogDblMaxDecl ="#define fLogDblMax log(1.79769e+308)\n";