summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxinjiang <xinjiang@multicorewareinc.com>2013-11-06 12:50:30 +0800
committerI-Jui (Ray) Sung <ray@multicorewareinc.com>2013-11-13 14:39:19 -0600
commit8ac2892999febef41b177826e5ace154b4bd1af5 (patch)
treeccb8a031ca2997794032d70e6ab119af97787a77
parentcbb414241e710fb6cf65f8533983407dc6cb2a70 (diff)
GPU Calc: implemented for CONFIDENCE
AMLOEXT-140 FIX Change-Id: I570bf1606358e9cd2b90d1e53e665d4110e4286d 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.cxx82
-rw-r--r--sc/source/core/opencl/op_statistical.hxx13
-rw-r--r--sc/source/core/opencl/opinlinefun_statistical.cxx183
4 files changed, 282 insertions, 0 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index e8738a067bac..c1ab234f4149 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1128,6 +1128,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i],new OpIPMT));
break;
+ case ocConfidence:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpConfidence));
+ 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 f27ab46caec1..2900cca5a8db 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -17,6 +17,7 @@
#include "interpre.hxx"
#include "formula/vectortoken.hxx"
#include <sstream>
+#include "opinlinefun_statistical.cxx"
using namespace formula;
@@ -853,6 +854,87 @@ void OpHarMean::GenSlidingWindowFunction(
ss << "}";
}
+void OpConfidence::BinInlineFun(std::set<std::string>& decls,
+ std::set<std::string>& funs)
+{
+ decls.insert(gaussinvDecl);
+ funs.insert(gaussinv);
+}
+
+void OpConfidence::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 << " double alpha = " << GetBottom() <<";\n";
+ ss << " double sigma = " << GetBottom() <<";\n";
+ ss << " double size = " << GetBottom() <<";\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);
+ ss << " int buffer_alpha_len = ";
+ ss << tmpCurDVR0->GetArrayLength();
+ ss << ";\n";
+ ss << " int buffer_sigma_len = ";
+ ss << tmpCurDVR1->GetArrayLength();
+ ss << ";\n";
+ ss << " int buffer_size_len = ";
+ ss << tmpCurDVR2->GetArrayLength();
+ ss << ";\n";
+#endif
+#ifdef ISNAN
+ ss << " if((gid0)>=buffer_alpha_len || isNan(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << "))\n";
+ ss << " alpha = 0;\n else\n";
+#endif
+ ss << " alpha = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+#ifdef ISNAN
+ ss << " if((gid0)>=buffer_sigma_len || isNan(";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss << "))\n";
+ ss << " sigma = 0;\n else\n";
+#endif
+ ss << " sigma = ";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+#ifdef ISNAN
+ ss << " if((gid0)>=buffer_size_len || isNan(";
+ ss << vSubArguments[2]->GenSlidingWindowDeclRef();
+ ss << "))\n";
+ ss << " size = 0;\n else\n";
+#endif
+ ss << " size = ";
+ ss << vSubArguments[2]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+ ss << " double rn = floor(size);\n";
+ ss << " if(sigma <= 0.0 || alpha <= 0.0 || alpha >= 1.0";
+ ss << "|| rn < 1.0)\n";
+ ss << " tmp = -DBL_MAX;\n";
+ ss << " else\n";
+ ss << " tmp = gaussinv(1.0 - alpha / 2.0) * sigma / sqrt( rn );\n";
+ ss << " return tmp;\n";
+ ss << "}";
+}
+
void OpRsq::GenSlidingWindowFunction(
std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments)
{
diff --git a/sc/source/core/opencl/op_statistical.hxx b/sc/source/core/opencl/op_statistical.hxx
index c91e0f4d379e..452a159e6c61 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -172,6 +172,19 @@ class OpVariationen2:public Normal{
const std::string sSymName, SubArguments &vSubArguments);
virtual std::string BinFuncName(void) const { return "OpVariationen2";}
};
+
+class OpConfidence: 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 "Confidence"; }
+};
}}
#endif
diff --git a/sc/source/core/opencl/opinlinefun_statistical.cxx b/sc/source/core/opencl/opinlinefun_statistical.cxx
new file mode 100644
index 000000000000..f2ba0abbc8ba
--- /dev/null
+++ b/sc/source/core/opencl/opinlinefun_statistical.cxx
@@ -0,0 +1,183 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef SC_OPENCL_OPINLINFUN_statistical
+#define SC_OPENCL_OPINLINFUN_statistical
+std::string fBigInvDecl ="#define fBigInv 2.22045e-016\n";
+std::string fLogDblMaxDecl ="#define fLogDblMax log(1.79769e+308)\n";
+std::string fHalfMachEpsDecl ="#define fHalfMachEps 0.5*2.22045e-016\n";
+std::string fMaxGammaArgumentDecl =
+"#define fMaxGammaArgument 171.624376956302\n";
+
+std::string gaussinvDecl = "double gaussinv(double x);\n";
+std::string gaussinv =
+"double gaussinv(double x)\n"
+"{\n"
+" double q,t,z;\n"
+" q=x-0.5;\n"
+" if(fabs(q)<=.425)\n"
+" {\n"
+" t=0.180625-q*q;\n"
+" z=\n"
+" q*\n"
+" (\n"
+" (\n"
+" (\n"
+" (\n"
+" (\n"
+" (\n"
+" (\n"
+" t*2509.0809287301226727+33430.575583588128105\n"
+" )\n"
+" *t+67265.770927008700853\n"
+" )\n"
+" *t+45921.953931549871457\n"
+" )\n"
+" *t+13731.693765509461125\n"
+" )\n"
+" *t+1971.5909503065514427\n"
+" )\n"
+" *t+133.14166789178437745\n"
+" )\n"
+" *t+3.387132872796366608\n"
+" )\n"
+" /\n"
+" (\n"
+" (\n"
+" (\n"
+" (\n"
+" (\n"
+" (\n"
+" (\n"
+" t*5226.495278852854561+28729.085735721942674\n"
+" )\n"
+" *t+39307.89580009271061\n"
+" )\n"
+" *t+21213.794301586595867\n"
+" )\n"
+" *t+5394.1960214247511077\n"
+" )\n"
+" *t+687.1870074920579083\n"
+" )\n"
+" *t+42.313330701600911252\n"
+" )\n"
+" *t+1.0\n"
+" );\n"
+" }\n"
+" else\n"
+" {\n"
+" if(q>0) t=1-x;\n"
+" else t=x;\n"
+" t=sqrt(-log(t));\n"
+" if(t<=5.0)\n"
+" {\n"
+" t+=-1.6;\n"
+" z=\n"
+" (\n"
+" (\n"
+" (\n"
+" (\n"
+" (\n"
+" (\n"
+" (\n"
+" t*7.7454501427834140764e-4+0.0227238449892691845833\n"
+" )\n"
+" *t+0.24178072517745061177\n"
+" )\n"
+" *t+1.27045825245236838258\n"
+" )\n"
+" *t+3.64784832476320460504\n"
+" )\n"
+" *t+5.7694972214606914055\n"
+" )\n"
+" *t+4.6303378461565452959\n"
+" )\n"
+" *t+1.42343711074968357734\n"
+" )\n"
+" /\n"
+" (\n"
+" (\n"
+" (\n"
+" (\n"
+" (\n"
+" (\n"
+" (\n"
+" t*1.05075007164441684324e-9+5.475938084995344946e-4\n"
+" )\n"
+" *t+0.0151986665636164571966\n"
+" )\n"
+" *t+0.14810397642748007459\n"
+" )\n"
+" *t+0.68976733498510000455\n"
+" )\n"
+" *t+1.6763848301838038494\n"
+" )\n"
+" *t+2.05319162663775882187\n"
+" )\n"
+" *t+1.0\n"
+" );\n"
+" }\n"
+" else\n"
+" {\n"
+" t+=-5.0;\n"
+" z=\n"
+" (\n"
+" (\n"
+" (\n"
+" (\n"
+" (\n"
+" (\n"
+" (\n"
+" t*2.01033439929228813265e-7+2.71155556874348757815e-5\n"
+" )\n"
+" *t+0.0012426609473880784386\n"
+" )\n"
+" *t+0.026532189526576123093\n"
+" )\n"
+" *t+0.29656057182850489123\n"
+" )\n"
+" *t+1.7848265399172913358\n"
+" )\n"
+" *t+5.4637849111641143699\n"
+" )\n"
+" *t+6.6579046435011037772\n"
+" )\n"
+" /\n"
+" (\n"
+" (\n"
+" (\n"
+" (\n"
+" (\n"
+" (\n"
+" (\n"
+" t*2.04426310338993978564e-15+1.4215117583164458887e-7\n"
+" )\n"
+" *t+1.8463183175100546818e-5\n"
+" )\n"
+" *t+7.868691311456132591e-4\n"
+" )\n"
+" *t+0.0148753612908506148525\n"
+" )\n"
+" *t+0.13692988092273580531\n"
+" )\n"
+" *t+0.59983220655588793769\n"
+" )\n"
+" *t+1.0\n"
+" );\n"
+" }\n"
+" if(q<0.0) z=-z;\n"
+" }\n"
+" return z;\n"
+"}\n";
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+