diff options
-rw-r--r-- | sc/source/core/opencl/formulagroupcl.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/opencl/op_math.cxx | 29 | ||||
-rw-r--r-- | sc/source/core/opencl/op_math.hxx | 8 |
3 files changed, 41 insertions, 0 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index dd6b169ec334..87ea577854a9 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -1088,6 +1088,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments( mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], new OpArcCos)); break; + case ocSqrt: + mvSubArguments.push_back(SoPHelper(ts, + ft->Children[i],new OpSqrt)); + break; case ocExternal: if ( !(pChild->GetExternal().compareTo(OUString( "com.sun.star.sheet.addin.Analysis.getEffect")))) diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx index b54ee0f2408b..5e4f3dfd6564 100644 --- a/sc/source/core/opencl/op_math.cxx +++ b/sc/source/core/opencl/op_math.cxx @@ -320,6 +320,35 @@ void OpTanH::GenSlidingWindowFunction(std::stringstream &ss, ss << " return tmp;\n"; ss << "}"; } +void OpSqrt::GenSlidingWindowFunction(std::stringstream &ss, + const std::string sSymName, SubArguments &vSubArguments) +{ + FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken(); + const formula::SingleVectorRefToken*tmpCurDVR= dynamic_cast<const + formula::SingleVectorRefToken *>(tmpCur); + ss << "\ndouble " << sSymName; + ss << "_"<< BinFuncName() <<"("; + for (unsigned i = 0; i < vSubArguments.size(); i++) + { + if (i) + ss << ","; + vSubArguments[i]->GenSlidingWindowDecl(ss); + } + ss << ")\n"; + ss << "{\n"; + ss << " int gid0=get_global_id(0);\n"; + ss << " double arg0 = "<< vSubArguments[0]->GenSlidingWindowDeclRef(); + ss << ";\n"; +#ifdef ISNAN + ss << " if(isNan(arg0)||(gid0>="; + ss << tmpCurDVR->GetArrayLength(); + ss << "))\n"; + ss << " arg0 = 0;\n"; +#endif + ss << " double tmp=sqrt(arg0);\n"; + ss << " return tmp;\n"; + ss << "}"; +} }} diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx index e888849d9334..0998b4f0123d 100644 --- a/sc/source/core/opencl/op_math.hxx +++ b/sc/source/core/opencl/op_math.hxx @@ -81,6 +81,14 @@ public: virtual std::string BinFuncName(void) const { return "TanH"; } }; +class OpSqrt: public Normal +{ +public: + virtual void GenSlidingWindowFunction(std::stringstream &ss, + const std::string sSymName, SubArguments &vSubArguments); + + virtual std::string BinFuncName(void) const { return "Sqrt"; } +}; }} #endif |