diff options
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/opencl/formulagroupcl.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/opencl/op_financial.cxx | 97 | ||||
-rw-r--r-- | sc/source/core/opencl/op_financial.hxx | 9 |
3 files changed, 111 insertions, 1 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 24647bf5982a..1cc0b9f48a95 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -1137,6 +1137,12 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments( mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], new OpPrice)); } + else if ( !(pChild->GetExternal().compareTo(OUString( + "com.sun.star.sheet.addin.Analysis.getCoupnum")))) + { + mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], + new OpCoupnum)); + } break; default: throw UnhandledToken(pChild, "unhandled opcode"); diff --git a/sc/source/core/opencl/op_financial.cxx b/sc/source/core/opencl/op_financial.cxx index a40a113ecf09..b5b9a5c6b616 100644 --- a/sc/source/core/opencl/op_financial.cxx +++ b/sc/source/core/opencl/op_financial.cxx @@ -2740,7 +2740,102 @@ void OpCoupdaysnc::GenSlidingWindowFunction( ss << "}"; } - void OpReceived::BinInlineFun(std::set<std::string>& decls, +void OpCoupnum::BinInlineFun(std::set<std::string>& decls, + std::set<std::string>& funs) +{ + decls.insert(IsLeapYearDecl);decls.insert(DaysInMonthDecl); + decls.insert(DaysToDateDecl);decls.insert(DateToDaysDecl); + decls.insert(GetNullDateDecl);decls.insert(lcl_GetcoupnumDecl); + decls.insert(coupnumDecl); + funs.insert(IsLeapYear);funs.insert(DaysInMonth); + funs.insert(DaysToDate);funs.insert(DateToDays); + funs.insert(GetNullDate); + funs.insert(lcl_Getcoupnum); + funs.insert(coupnum); +} +void OpCoupnum::GenSlidingWindowFunction(std::stringstream &ss, + const std::string sSymName, SubArguments &vSubArguments) +{ + ss << "\ndouble " << sSymName; + ss << "_"<< BinFuncName() <<"("; + for (unsigned i = 0; i < vSubArguments.size(); i++) + { + if (i) + ss << ","; + vSubArguments[i]->GenSlidingWindowDecl(ss); + } + ss << ") {\n "; + ss << "double tmp = " << GetBottom() <<";\n "; + ss << "int gid0 = get_global_id(0);\n "; + ss << "int nSettle,nMat,nFreq,nBase;\n "; +#ifdef ISNAN + FormulaToken* tmpCur0 = vSubArguments[0]->GetFormulaToken(); + const formula::SingleVectorRefToken*tmpCurDVR0= dynamic_cast<const + formula::SingleVectorRefToken *>(tmpCur0); + FormulaToken* tmpCur1 = vSubArguments[1]->GetFormulaToken(); + const formula::SingleVectorRefToken*tmpCurDVR1= dynamic_cast<const + formula::SingleVectorRefToken *>(tmpCur1); + FormulaToken* tmpCur2 = vSubArguments[2]->GetFormulaToken(); + const formula::SingleVectorRefToken*tmpCurDVR2= dynamic_cast<const + formula::SingleVectorRefToken *>(tmpCur2); + FormulaToken* tmpCur3 = vSubArguments[3]->GetFormulaToken(); + const formula::SingleVectorRefToken*tmpCurDVR3= dynamic_cast<const + formula::SingleVectorRefToken *>(tmpCur3); + ss<< "int buffer_nSettle_len = "; + ss<< tmpCurDVR0->GetArrayLength(); + ss << ";\n "; + ss<< "int buffer_nMat_len = "; + ss<< tmpCurDVR1->GetArrayLength(); + ss << ";\n "; + ss<< "int buffer_nFreq_len = "; + ss<< tmpCurDVR2->GetArrayLength(); + ss << ";\n "; + ss<< "int buffer_nBase_len = "; + ss<< tmpCurDVR3->GetArrayLength(); + ss << ";\n "; +#endif +#ifdef ISNAN + ss <<"if(gid0 >= buffer_nSettle_len || isNan("; + ss <<vSubArguments[0]->GenSlidingWindowDeclRef(); + ss <<"))\n "; + ss <<"nSettle = 0;\n else\n "; +#endif + ss << "nSettle=(int)"; + ss << vSubArguments[0]->GenSlidingWindowDeclRef(); + ss <<";\n "; +#ifdef ISNAN + ss <<"if(gid0 >= buffer_nMat_len || isNan("; + ss <<vSubArguments[1]->GenSlidingWindowDeclRef(); + ss <<"))\n "; + ss <<"nMat = 0;\n else\n "; +#endif + ss << "nMat=(int)"; + ss << vSubArguments[1]->GenSlidingWindowDeclRef(); + ss << ";\n "; +#ifdef ISNAN + ss <<"if(gid0 >= buffer_nFreq_len || isNan("; + ss <<vSubArguments[2]->GenSlidingWindowDeclRef(); + ss <<"))\n "; + ss <<"nFreq = 0;\n else\n "; +#endif + ss << "nFreq=(int)"; + ss << vSubArguments[2]->GenSlidingWindowDeclRef(); + ss <<";\n "; +#ifdef ISNAN + ss <<"if(gid0 >= buffer_nBase_len || isNan("; + ss <<vSubArguments[3]->GenSlidingWindowDeclRef(); + ss <<"))\n "; + ss <<"nBase = 0;\n else\n "; +#endif + ss << "nBase=(int)"; + ss << vSubArguments[3]->GenSlidingWindowDeclRef(); + ss << ";\n "; + ss <<"tmp = coupnum(nSettle,nMat,nFreq,nBase);\n "; + ss << "return tmp;\n"; + ss << "}"; +} + +void OpReceived::BinInlineFun(std::set<std::string>& decls, std::set<std::string>& funs) { decls.insert(GetYearDiffDecl);decls.insert(GetDiffDateDecl); diff --git a/sc/source/core/opencl/op_financial.hxx b/sc/source/core/opencl/op_financial.hxx index fc730767e554..6bc3c19927e4 100644 --- a/sc/source/core/opencl/op_financial.hxx +++ b/sc/source/core/opencl/op_financial.hxx @@ -315,7 +315,16 @@ public: virtual std::string BinFuncName(void) const { return "Coupdaysnc"; } }; +class OpCoupnum:public Normal +{ +public: + virtual std::string GetBottom(void) { return "0";} + virtual void GenSlidingWindowFunction(std::stringstream &ss, + const std::string sSymName, SubArguments &vSubArguments); + virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>&); + virtual std::string BinFuncName(void) const { return "Coupnum"; } +}; class OpReceived:public Normal { public: |