summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/opencl/op_math.cxx8
-rw-r--r--sc/source/core/opencl/op_math.hxx1
-rw-r--r--sc/source/core/opencl/opinlinefun_math.hxx29
3 files changed, 37 insertions, 1 deletions
diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx
index 3958781a6512..85fdfa1177c5 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1396,6 +1396,12 @@ void OpArcSinHyp::GenSlidingWindowFunction(std::stringstream &ss,
ss << " return log( tmp + pow((pown(tmp, 2) + 1.0), 0.5));\n";
ss << "}";
}
+void OpArcTan2::BinInlineFun(std::set<std::string>& decls,
+ std::set<std::string>& funs)
+{
+ decls.insert(atan2Decl);
+ funs.insert(atan2Content);
+}
void OpArcTan2::GenSlidingWindowFunction(std::stringstream &ss,
const std::string sSymName, SubArguments &vSubArguments)
{
@@ -1432,7 +1438,7 @@ void OpArcTan2::GenSlidingWindowFunction(std::stringstream &ss,
ss << " else \n ";
#endif
ss << " y_num = "<< vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
- ss << " return atan2(y_num, x_num);\n";
+ ss << " return arctan2(y_num, x_num);\n";
ss << "}";
}
void OpArcTan::GenSlidingWindowFunction(std::stringstream &ss,
diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx
index b0d79807bca8..a174bef0da61 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -175,6 +175,7 @@ public:
const std::string sSymName, SubArguments &vSubArguments);
virtual std::string GetBottom(void) { return "0.0"; }
virtual std::string BinFuncName(void) const { return "ScATan2"; }
+ virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>&);
};
class OpArcTan:public Normal{
public:
diff --git a/sc/source/core/opencl/opinlinefun_math.hxx b/sc/source/core/opencl/opinlinefun_math.hxx
index b641c522e898..a8130919245a 100644
--- a/sc/source/core/opencl/opinlinefun_math.hxx
+++ b/sc/source/core/opencl/opinlinefun_math.hxx
@@ -56,6 +56,35 @@ std::string local_cosh =
" double nVal = (exp(n) + exp(-n)) / 2;\n"
" return nVal;\n"
"}\n";
+std::string atan2Decl = "double arctan2(double y, double x);\n";
+std::string atan2Content =
+"double arctan2(double y, double x)\n"
+"{\n"
+" if(y==0.0)\n"
+" return 0.0;\n"
+" double a,num,den,tmpPi;\n"
+" int flag;\n"
+" tmpPi = 0;\n"
+" if (fabs(x) >= fabs(y))\n"
+" {\n"
+" num = y;\n"
+" den = x;\n"
+" flag = 1;\n"
+" if (x < 0.0)\n"
+" tmpPi = M_PI;\n"
+" }\n"
+" if(fabs(x) < fabs(y))\n"
+" {\n"
+" num = x;\n"
+" den = y;\n"
+" flag = -1;\n"
+" tmpPi = M_PI_2;\n"
+" }\n"
+" a = atan(num/den);\n"
+" a = flag==1?a:-a;\n"
+" a = a + (y >= 0.0 ? tmpPi : -tmpPi);\n"
+" return a;\n"
+"}\n";
#endif //SC_OPENCL_OPINLINFUN_MATH