summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormingli <mingli@multicorewareinc.com>2013-11-06 13:07:59 +0800
committerI-Jui (Ray) Sung <ray@multicorewareinc.com>2013-11-13 14:39:20 -0600
commit4f152b68ffda7320de2a8f85379efb823c482fab (patch)
tree25eb6fdb3e5df7924870389a6a680844748d5776
parentb5febdfa86d6cbaeb1653716d2f13b395cea3472 (diff)
GPU Calc: implemented for INTERCEPT
AMLOEXT-93 FIX Change-Id: Iec88fa93b875f41596ff92622e64f01f8e967319 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.cxx4
-rw-r--r--sc/source/core/opencl/op_statistical.cxx98
-rw-r--r--sc/source/core/opencl/op_statistical.hxx7
3 files changed, 109 insertions, 0 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index c1ab234f4149..fd1349068d8e 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1132,6 +1132,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpConfidence));
break;
+ case ocIntercept:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpIntercept));
+ 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 2900cca5a8db..01e07951ac71 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -1858,6 +1858,104 @@ void OpKurt:: GenSlidingWindowFunction(std::stringstream &ss,
ss<< " return tmp;\n";
ss<< "}";
}
+void OpIntercept::GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments)
+{
+ FormulaToken *pCur = vSubArguments[0]->GetFormulaToken();
+ assert(pCur);
+ const formula::DoubleVectorRefToken* pCurDVR =
+ dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
+ size_t nCurWindowSize = pCurDVR->GetRefRowSize();
+ FormulaToken *pCur1 = vSubArguments[1]->GetFormulaToken();
+ assert(pCur1);
+ const formula::DoubleVectorRefToken* pCurDVR1 =
+ dynamic_cast<const formula::DoubleVectorRefToken *>(pCur1);
+ size_t nCurWindowSize1 = pCurDVR1->GetRefRowSize();
+ 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 << " double fSumX = 0.0;\n";
+ ss << " double fSumY = 0.0;\n";
+ ss << " double fSumDeltaXDeltaY = 0.0;\n";
+ ss << " double fSumSqrDeltaX = 0.0;\n";
+ ss << " int length="<<nCurWindowSize;
+ ss << ";\n";
+ ss << " int length1= "<<nCurWindowSize1;
+ ss << ";\n";
+ ss << " if(length!=length1)\n";
+ ss << " return 0;\n";
+ ss << " double tmp = 0;\n";
+ ss << " for (int i = 0; i <" << nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+ ss << " double arg0 = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+ ss << " double arg1 = ";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+#ifdef ISNAN
+ ss << " if(isNan(arg0)||((gid0+i)>=";
+ ss << pCurDVR->GetArrayLength();
+ ss << "))\n";
+ ss << " {\n";
+ ss << " length--;\n";
+ ss << " continue;\n";
+ ss << " }\n";
+#endif
+#ifdef ISNAN
+ ss << " if(isNan(arg1)||((gid0+i)>=";
+ ss << pCurDVR1->GetArrayLength();
+ ss << "))\n";
+ ss << " {\n";
+ ss << " length--;\n";
+ ss << " continue;\n";
+ ss << " }\n";
+#endif
+ ss << " fSumY+=arg0;\n";
+ ss << " fSumX+=arg1;\n";
+ ss << " }\n";
+ ss <<" double fMeanX = fSumX / length;\n";
+ ss <<" double fMeanY = fSumY / length;\n";
+ ss << " for (int i = 0; i <" << nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+ ss << " double arg0 = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+ ss << " double arg1 = ";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+#ifdef ISNAN
+ ss << " if(isNan(arg0)||((gid0+i)>=";
+ ss << pCurDVR->GetArrayLength();
+ ss << "))\n";
+ ss << " {\n";
+ ss << " continue;\n";
+ ss << " }\n";
+#endif
+#ifdef ISNAN
+ ss << " if(isNan(arg1)||((gid0+i)>=";
+ ss <<pCurDVR1->GetArrayLength();
+ ss <<"))\n";
+ ss << " {";
+ ss << " continue;\n";
+ ss << " }\n";
+#endif
+ ss << " fSumDeltaXDeltaY+=(arg1 - fMeanX) * (arg0 - fMeanY);";
+ ss << ";\n";
+ ss << " fSumSqrDeltaX+=(arg1 - fMeanX) * (arg1 - fMeanX);\n";
+ ss << " }\n";
+ ss << " tmp = fMeanY - fSumDeltaXDeltaY / fSumSqrDeltaX";
+ ss << "* fMeanX;\n";
+ ss << " return tmp;\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 452a159e6c61..1803e08227d3 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -185,6 +185,13 @@ public:
virtual std::string BinFuncName(void) const { return "Confidence"; }
};
+class OpIntercept: public Normal
+{
+public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments);
+ virtual std::string BinFuncName(void) const { return "Intercept"; }
+};
}}
#endif