diff options
author | yiming ju <yiming@multicorewareinc.com> | 2013-11-08 12:47:15 +0800 |
---|---|---|
committer | I-Jui (Ray) Sung <ray@multicorewareinc.com> | 2013-11-14 14:09:44 -0600 |
commit | 800eb0eb9a145c878d8dcaf42c09fa8b66d36771 (patch) | |
tree | 388ba2d5fa69a27523bbf8849435baa93f738072 | |
parent | c7252be5c2fd0ef58167ea0c0e9f4f281cd9eacc (diff) |
GPU Calc: implemented CHISQDIST
AMLOEXT-139 FIX
Change-Id: Ic923ec57c4d375ee59ba2033b38c956e535043c7
Signed-off-by: haochen <haochen@multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray@multicorewareinc.com>
-rw-r--r-- | sc/source/core/opencl/formulagroupcl.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/opencl/op_statistical.cxx | 60 | ||||
-rw-r--r-- | sc/source/core/opencl/op_statistical.hxx | 8 |
3 files changed, 72 insertions, 0 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 507fe7d528da..a4e99e0d172d 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -1228,6 +1228,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments( mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], new OpOdd)); break; + case ocChiSqDist: + mvSubArguments.push_back(SoPHelper(ts, + ft->Children[i],new OpChiSqDist)); + break; case ocExternal: if ( !(pChild->GetExternal().compareTo(OUString( "com.sun.star.sheet.addin.Analysis.getEffect")))) diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx index fc93c03dd530..a9cfbd2b1530 100644 --- a/sc/source/core/opencl/op_statistical.cxx +++ b/sc/source/core/opencl/op_statistical.cxx @@ -2941,6 +2941,66 @@ void OpChiDist::GenSlidingWindowFunction( ss << " return tmp;\n"; ss << "}\n"; } +void OpChiSqDist::BinInlineFun(std::set<std::string>& decls, + std::set<std::string>& funs) +{ + decls.insert(fMaxGammaArgumentDecl);decls.insert(GetChiSqDistCDFDecl); + decls.insert(GetChiSqDistPDFDecl);decls.insert(GetLowRegIGammaDecl); + decls.insert(GetGammaContFractionDecl);decls.insert(GetGammaSeriesDecl); + decls.insert(fHalfMachEpsDecl);decls.insert(F_PIDecl); + decls.insert(fBigInvDecl); + + funs.insert(GetGammaContFraction);funs.insert(GetChiSqDistCDF); + funs.insert(GetChiSqDistPDF);funs.insert(GetLowRegIGamma); + funs.insert(GetGammaSeries); +} + +void OpChiSqDist::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 << " int gid0 = get_global_id(0);\n"; + ss << " int singleIndex = gid0;\n"; + ss << " double result = 0;\n"; + if(vSubArguments.size()<2) + { + ss << " result = -DBL_MAX;\n"; + ss << " return result;\n"; + }else + { + GenTmpVariables(ss,vSubArguments); + CheckAllSubArgumentIsNan(ss,vSubArguments); + if(vSubArguments.size() == 2) + { + ss << " int tmp2 = 1;\n"; + } + ss << "tmp1 = floor(tmp1);\n"; + + ss << " if(tmp1 < 1.0)\n"; + ss << " result = -DBL_MAX;\n"; + ss << " else\n"; + ss << " {\n"; + ss << " if(tmp2)\n"; + ss << " result =GetChiSqDistCDF(tmp0,tmp1);\n"; + ss << " else\n"; + ss << " result =GetChiSqDistPDF(tmp0,tmp1);\n"; + ss << " }\n"; + ss << " return result;\n"; + ss << "}"; + } + +} + + }} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/opencl/op_statistical.hxx b/sc/source/core/opencl/op_statistical.hxx index dedebf5843e8..ea006f79cda0 100644 --- a/sc/source/core/opencl/op_statistical.hxx +++ b/sc/source/core/opencl/op_statistical.hxx @@ -253,6 +253,14 @@ class OpChiDist:public Normal{ virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>&); virtual std::string BinFuncName(void) const { return "OpChiDist"; } }; +class OpChiSqDist: public CheckVariables +{ +public: + virtual void GenSlidingWindowFunction(std::stringstream &ss, + const std::string sSymName, SubArguments &vSubArguments); + virtual std::string BinFuncName(void) const { return "ChiSqDist"; } + virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>& ); +}; }} #endif |