diff options
author | haochen <haochen@multicorewareinc.com> | 2013-10-25 10:36:05 +0800 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-10-29 17:00:24 -0400 |
commit | 5b83739280bce1751547371803f27d5ea4009c8a (patch) | |
tree | 48962fc86260c1e628059490ae11b7e359631ed8 /sc | |
parent | 52cf3dad67e7120220ea5fd5770084119fde2475 (diff) |
Implement fix for NEGBINOMDIST in GPU Calc
Change-Id: I327737e899b88448a195f6d990a9a6552346a74c
Signed-off-by: Wei Wei <weiwei@multicorewareinc.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/opencl/OP_Statistical.cxx | 76 | ||||
-rw-r--r-- | sc/source/core/opencl/formulagroupcl.cxx | 4 |
2 files changed, 80 insertions, 0 deletions
diff --git a/sc/source/core/opencl/OP_Statistical.cxx b/sc/source/core/opencl/OP_Statistical.cxx index 2f9b5c27494f..306590ffc9cd 100644 --- a/sc/source/core/opencl/OP_Statistical.cxx +++ b/sc/source/core/opencl/OP_Statistical.cxx @@ -321,7 +321,83 @@ public: } virtual std::string BinFuncName(void) const { return "Correl"; } }; +class OpNegbinomdist: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"; + ss << "{\n\t"; + ss << "double f,s,p;\n\t"; + ss << " int gid0=get_global_id(0);\n\t"; +#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); + ss<< "int buffer_f_len = "; + ss<< tmpCurDVR0->GetArrayLength(); + ss << ";\n\t"; + ss<< "int buffer_s_len = "; + ss<< tmpCurDVR1->GetArrayLength(); + ss << ";\n\t"; + + ss<< "int buffer_p_len = "; + ss<< tmpCurDVR2->GetArrayLength(); + ss << ";\n\t"; +#endif +#ifdef ISNAN + ss<<"if((gid0)>=buffer_p_len || isNan("; + ss << vSubArguments[2]->GenSlidingWindowDeclRef(); + ss<<"))\n\t\t"; + ss<<"p = 0;\n\telse \n\t\t"; +#endif + ss << " p = "<<vSubArguments[2]->GenSlidingWindowDeclRef(); + ss << " ;\n\t"; +#ifdef ISNAN + ss<<"if((gid0)>=buffer_s_len || isNan("; + ss << vSubArguments[1]->GenSlidingWindowDeclRef(); + ss<<"))\n\t\t"; + ss<<"s = 0;\n\telse \n\t\t"; +#endif + ss << " s = "<<vSubArguments[1]->GenSlidingWindowDeclRef(); + ss << " ;\n\t"; +#ifdef ISNAN + ss<<"if((gid0)>=buffer_f_len || isNan("; + ss << vSubArguments[0]->GenSlidingWindowDeclRef(); + ss<<"))\n\t\t"; + ss<<"f = 0;\n\telse \n\t\t"; +#endif + ss << " f = "<<vSubArguments[0]->GenSlidingWindowDeclRef(); + ss << " ;\n\t"; + ss << " double q = 1.0 - p;\n\t"; + ss << " double fFactor = pow(p,s);\n\t"; + ss << " for(int i=0; i<f; i++)\n\t"; + ss << " {\n\t"; + ss << " fFactor *= ((double)i+s)/((double)i+1.0)*q;\n\t"; + ss << " }\n\t"; + ss << " double tmp=fFactor;\n\t"; + ss << " return tmp;\n"; + ss << "}\n"; + } + virtual std::string BinFuncName(void) const { return "OpNegbinomdist"; } +}; class OpGammaLn:public Normal{ public: virtual void GenSlidingWindowFunction(std::stringstream &ss, diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 3a71a2be64a8..e1d1a9a183bb 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -807,6 +807,10 @@ DynamicKernelSoPArguments<Op>::DynamicKernelSoPArguments(const std::string &s, mvSubArguments.push_back(SoPHelper<OpCos>(ts, ft->Children[i])); break; + case ocNegBinomVert : + mvSubArguments.push_back(SoPHelper<OpNegbinomdist>(ts, + ft->Children[i])); + break; case ocExternal: if ( !(pChild->GetExternal().compareTo(OUString( "com.sun.star.sheet.addin.Analysis.getEffect")))) |