summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorI-Jui (Ray) Sung <ray@multicorewareinc.com>2013-10-19 00:10:51 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-10-29 16:59:57 -0400
commit3331bed22b70f37c1d9d193417276361b171f7e8 (patch)
tree03f7db41a964d95011e46accaabbb49bb5c04f88
parent9c7cb0d33f887b972587e630caf80f6ffe557429 (diff)
Support TBILLEQ
Change-Id: I23c538cd6c2244f84e4d4d526adfdba460cc0312
-rw-r--r--sc/source/core/opencl/formulagroupcl.cxx42
-rw-r--r--sc/source/core/opencl/formulagroupcl_finacial.hxx37
2 files changed, 79 insertions, 0 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index eadb31483238..a94b894fd22d 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -667,6 +667,42 @@ class OpXNPV:public XNPV{
virtual std::string BinFuncName(void) const { return "XNPV"; }
};
+class OpTbilleq:public Normal{
+ public:
+ virtual void 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\t";
+ ss << " int gid0 = get_global_id(0);\n";
+ ss << "double tmp = 0;\n\t";
+ ss << "double tmp000=";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss <<";\n";
+
+ ss << "double tmp001=";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss <<";\n";
+
+ ss << "double tmp002=";
+ ss << vSubArguments[2]->GenSlidingWindowDeclRef();
+ ss <<";\n";
+
+ ss<<"tmp001++;\n";
+ ss<<"int nDiff = GetDiffDate360( GetNullDate(), tmp000, tmp001, true);\n";
+ ss<<"tmp =( 365 * tmp002 ) / ( 360 - ( tmp002 * ( nDiff ) ) );\n";
+ ss << "return tmp;\n";
+ ss << "}";
+ }
+ virtual std::string BinFuncName(void) const { return "fTbilleq"; }
+};
class OpCumprinc: public Normal
{
public:
@@ -945,6 +981,12 @@ DynamicKernelSoPArguments<Op>::DynamicKernelSoPArguments(const std::string &s,
mvSubArguments.push_back(SoPHelper<OpReceived>(ts,
ft->Children[i]));
}
+ if( !(pChild->GetExternal().compareTo(OUString(
+ "com.sun.star.sheet.addin.Analysis.getTbilleq"))))
+ {
+ mvSubArguments.push_back(SoPHelper<OpTbilleq>(ts,
+ ft->Children[i]));
+ }
break;
default:
diff --git a/sc/source/core/opencl/formulagroupcl_finacial.hxx b/sc/source/core/opencl/formulagroupcl_finacial.hxx
index 2eed2369ca24..6cc6ee8063f8 100644
--- a/sc/source/core/opencl/formulagroupcl_finacial.hxx
+++ b/sc/source/core/opencl/formulagroupcl_finacial.hxx
@@ -331,5 +331,42 @@ char* finacialFunc =
"\t int nTotalDays = GetDiffDate( nNullDate, nStartDate, nEndDate, nMode, &nDays1stYear );\n"
"\t double result=(double)(nTotalDays)/(nDays1stYear);\n"
"\t return result;\n"
+"}\n"
+"int GetDiffDate360_(\n"
+" int nDay1, int nMonth1, int nYear1, bool bLeapYear1,\n"
+" int nDay2, int nMonth2, int nYear2,\n"
+" bool bUSAMethod )\n"
+"{\n"
+" if( nDay1 == 31 )\n"
+" nDay1--;\n"
+" else if( bUSAMethod && ( nMonth1 == 2 && ( nDay1 == 29 || ( nDay1 == 28 && !bLeapYear1 ) ) ) )\n"
+" nDay1 = 30;\n"
+" if( nDay2 == 31 )\n"
+" {\n"
+" if( bUSAMethod && nDay1 != 30 )\n"
+" {\n"
+" nDay2 = 1;\n"
+" if( nMonth2 == 12 )\n"
+" {\n"
+" nYear2++;\n"
+" nMonth2 = 1;\n"
+" }\n"
+" else\n"
+" nMonth2++;\n"
+" }\n"
+" else\n"
+" nDay2 = 30;\n"
+" }\n"
+" return nDay2 + nMonth2 * 30 + nYear2 * 360 - nDay1 - nMonth1 * 30 - nYear1 * 360;\n"
+"}\n"
+
+"int GetDiffDate360( int nNullDate, int nDate1, int nDate2, bool bUSAMethod )\n"
+"{\n"
+" nDate1 += nNullDate;\n"
+" nDate2 += nNullDate;\n"
+" int nDay1, nMonth1, nYear1, nDay2, nMonth2, nYear2;\n"
+" DaysToDate( nDate1, &nDay1, &nMonth1, &nYear1 );\n"
+" DaysToDate( nDate2, &nDay2, &nMonth2, &nYear2 );\n"
+" return GetDiffDate360_( nDay1, nMonth1, nYear1, IsLeapYear( nYear1 ), nDay2, nMonth2, nYear2, bUSAMethod );\n"
"}\n";