[Libreoffice-commits] core.git: 41 commits - sc/qa sc/source
I-Jui Sung (Ray)
ray at multicorewareinc.com
Thu Nov 14 12:10:18 PST 2013
sc/qa/unit/data/ods/opencl/math/cot.ods |binary
sc/qa/unit/data/ods/opencl/math/coth.ods |binary
sc/qa/unit/data/ods/opencl/math/csch.ods |binary
sc/qa/unit/data/ods/opencl/math/exp.ods |binary
sc/qa/unit/data/ods/opencl/math/floor.ods |binary
sc/qa/unit/data/ods/opencl/math/log10.ods |binary
sc/qa/unit/data/ods/opencl/math/power.ods |binary
sc/qa/unit/data/ods/opencl/statistical/BetaDist.ods |binary
sc/qa/unit/data/ods/opencl/statistical/CHISQDIST.ods |binary
sc/qa/unit/data/ods/opencl/statistical/CHISQINV.ods |binary
sc/qa/unit/data/xls/opencl/financial/NPER1.xls |binary
sc/qa/unit/data/xls/opencl/math/odd.xls |binary
sc/qa/unit/data/xls/opencl/statistical/B.xls |binary
sc/qa/unit/data/xls/opencl/statistical/ChiDist.xls |binary
sc/qa/unit/data/xls/opencl/statistical/Expondist.xls |binary
sc/qa/unit/data/xls/opencl/statistical/FInv.xls |binary
sc/qa/unit/data/xls/opencl/statistical/FTest.xls |binary
sc/qa/unit/data/xls/opencl/statistical/Fdist.xls |binary
sc/qa/unit/data/xls/opencl/statistical/GammaInv.xls |binary
sc/qa/unit/data/xls/opencl/statistical/Var.xls |binary
sc/qa/unit/opencl-test.cxx | 516 +++++++
sc/source/core/opencl/formulagroupcl.cxx | 95 +
sc/source/core/opencl/op_financial.cxx | 147 +
sc/source/core/opencl/op_financial.hxx | 2
sc/source/core/opencl/op_math.cxx | 269 +++
sc/source/core/opencl/op_math.hxx | 58
sc/source/core/opencl/op_statistical.cxx | 1399 +++++++++++++++++++
sc/source/core/opencl/op_statistical.hxx | 94 +
sc/source/core/opencl/opinlinefun_math.hxx | 26
sc/source/core/opencl/opinlinefun_statistical.cxx | 20
sc/source/core/tool/token.cxx | 18
31 files changed, 2572 insertions(+), 72 deletions(-)
New commits:
commit 1b5f5b0325e8ace49da154c0275d3d6894acc809
Author: I-Jui (Ray) Sung <ray at multicorewareinc.com>
Date: Thu Nov 14 12:27:31 2013 -0600
GPU Calc: fix compiler warnings in OpFTest::GenSlidingWindowFunction
Change-Id: I8c210de8274567f32aef2300c24fcae945ba49e9
diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx
index ec948c9..a686e5d 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -3599,16 +3599,15 @@ void OpFTest::GenSlidingWindowFunction(std::stringstream &ss,
ss << " double tmp = 0;\n";
for (unsigned i = 0; i < vSubArguments.size(); i++)
{
- FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
- assert(pCur);
- if (pCur->GetType() == formula::svDoubleVectorRef)
+ FormulaToken *pCurSub = vSubArguments[i]->GetFormulaToken();
+ assert(pCurSub);
+ if (pCurSub->GetType() == formula::svDoubleVectorRef)
{
const formula::DoubleVectorRefToken* pDVR =
- dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
- size_t nCurWindowSize = pDVR->GetRefRowSize();
+ dynamic_cast<const formula::DoubleVectorRefToken *>(pCurSub);
ss << " for (int i = ";
#ifdef ISNAN
- ss << "0; i < "<< nCurWindowSize << "; i++){\n";
+ ss << "0; i < "<< pDVR->GetRefRowSize() << "; i++){\n";
ss << " double arg"<<i<<" = ";
ss << vSubArguments[i]->GenSlidingWindowDeclRef();
ss << ";\n";
@@ -3626,21 +3625,21 @@ void OpFTest::GenSlidingWindowFunction(std::stringstream &ss,
ss << " * arg"<<i<<";\n";
ss << " }\n";
#endif
- }
- else if (pCur->GetType() == formula::svSingleVectorRef)
- {
+ }
+ else if (pCurSub->GetType() == formula::svSingleVectorRef)
+ {
#ifdef ISNAN
- ss << "return HUGE_VAL";
+ ss << "return HUGE_VAL";
#endif
- }
- else if (pCur->GetType() == formula::svDouble)
- {
+ }
+ else if (pCurSub->GetType() == formula::svDouble)
+ {
#ifdef ISNAN
- ss << "return HUGE_VAL";
+ ss << "return HUGE_VAL";
#endif
- }
}
- ss << " double fS1 = (fSumSqr1-fSum1*fSum1/length0)/(length0-1.0);\n"
+ }
+ ss << " double fS1 = (fSumSqr1-fSum1*fSum1/length0)/(length0-1.0);\n"
" double fS2 = (fSumSqr2-fSum2*fSum2/length1)/(length1-1.0);\n"
" double fF, fF1, fF2;\n"
" if (fS1 > fS2)\n"
@@ -3656,8 +3655,8 @@ void OpFTest::GenSlidingWindowFunction(std::stringstream &ss,
" fF2 = length0-1.0;\n"
" }\n"
" tmp = 2.0*GetFDist(fF, fF1, fF2);\n";
- ss << " return tmp;\n";
- ss << "}";
+ ss << " return tmp;\n";
+ ss << "}";
}
void OpB::BinInlineFun(std::set<std::string>& decls,
std::set<std::string>& funs)
commit 1a0370b48d20ed16c7c33d058482cec7427e8868
Author: minwang <min at multicorewareinc.com>
Date: Sat Nov 9 13:24:10 2013 +0800
GPU Calc: unit test cases for EXPONDIST
Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
AMLOEXT-151BUG
Change-Id: Iaee4276e29ff469e5527e678fdf296a11af173a1
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/qa/unit/data/xls/opencl/statistical/Expondist.xls b/sc/qa/unit/data/xls/opencl/statistical/Expondist.xls
new file mode 100644
index 0000000..63efa27
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/statistical/Expondist.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index d287fd1..58f8321 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -197,6 +197,7 @@ public:
void testMathFormulaCscH();
void testMathFormulaExp();
void testMathFormulaLog10();
+ void testStatisticalFormulaExpondist();
CPPUNIT_TEST_SUITE(ScOpenclTest);
CPPUNIT_TEST(testSharedFormulaXLS);
CPPUNIT_TEST(testFinacialFormula);
@@ -325,6 +326,7 @@ public:
CPPUNIT_TEST(testMathFormulaCscH);
CPPUNIT_TEST(testMathFormulaExp);
CPPUNIT_TEST(testMathFormulaLog10);
+ CPPUNIT_TEST(testStatisticalFormulaExpondist);
CPPUNIT_TEST_SUITE_END();
private:
@@ -3300,6 +3302,29 @@ void ScOpenclTest::testMathFormulaBitAnd()
xDocSh->DoClose();
xDocShRes->DoClose();
}
+//[AMLOEXT-151]
+void ScOpenclTest::testStatisticalFormulaExpondist()
+{
+ if (!detectOpenCLDevice())
+ return;
+ ScDocShellRef xDocSh = loadDoc("opencl/statistical/Expondist.", XLS);
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+ enableOpenCL();
+ pDoc->CalcAll();
+ ScDocShellRef xDocShRes = loadDoc("opencl/statistical/Expondist.", XLS);
+ ScDocument* pDocRes = xDocShRes->GetDocument();
+ CPPUNIT_ASSERT(pDocRes);
+ // Check the results of formula cells in the shared formula range.
+ for (SCROW i = 0; i <= 9; ++i)
+ {
+ double fLibre = pDoc->GetValue(ScAddress(3,i,0));
+ double fExcel = pDocRes->GetValue(ScAddress(3,i,0));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+ }
+ xDocSh->DoClose();
+ xDocShRes->DoClose();
+}
//[AMLOEXT-153]
void ScOpenclTest::testMathFormulaOdd()
{
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index fa4b856..3539a4f 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1429,6 +1429,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
case ocBetaDist:
case ocExp:
case ocLog10:
+ case ocExpDist:
// Don't change the state.
break;
default:
commit db9432fbcf497e4961184ade7ca81784f1501dff
Author: minwang <min at multicorewareinc.com>
Date: Sat Nov 9 13:30:15 2013 +0800
GPU Calc: implemented EXPONDIST
AMLOEXT-151 FIX
Change-Id: I0a9e743071ad767714c6664e48f2b37d6475d27e
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 13f9050..f1eee2a 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1262,10 +1262,16 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
ft->Children[i], new OpCscH));
break;
case ocExp:
- mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], new OpExp));
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpExp));
break;
case ocLog10:
- mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], new OpLog10));
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpLog10));
+ break;
+ case ocExpDist:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpExponDist));
break;
case ocExternal:
if ( !(pChild->GetExternal().compareTo(OUString(
diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx
index e30b4d9..ec948c9 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -254,6 +254,92 @@ void OpVar::GenSlidingWindowFunction(std::stringstream &ss,
ss << " return vSum / (fCount - 1.0);\n";
ss << "}\n";
}
+void OpExponDist::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 = 0;\n";
+ ss << " int gid0 = get_global_id(0);\n";
+ ss << " double rx,rlambda,rkum;\n";
+#ifdef ISNAN
+ FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken();
+ FormulaToken *tmpCur1 = vSubArguments[1]->GetFormulaToken();
+ FormulaToken *tmpCur2 = vSubArguments[2]->GetFormulaToken();
+#endif
+ ss <<" rx = "<<vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss <<";\n";
+ ss <<" rlambda = "<<vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss <<";\n";
+ ss <<" rkum = "<<vSubArguments[2]->GenSlidingWindowDeclRef();
+ ss <<";\n";
+#ifdef ISNAN
+ if(tmpCur0->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR0= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur0);
+ ss<< " int buffer_x_len = "<<tmpCurDVR0->GetArrayLength();
+ ss<< ";\n";
+ ss <<" if(gid0 >= buffer_x_len || isNan(";
+ ss <<vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss <<"))\n";
+ ss <<" rx = 0;\n";
+ }
+#endif
+#ifdef ISNAN
+ if(tmpCur1->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR1= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur1);
+ ss<< " int buffer_lambda_len = "<< tmpCurDVR1->GetArrayLength();
+ ss<< ";\n";
+ ss <<" if(gid0 >= buffer_lambda_len || isNan(";
+ ss <<vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss <<"))\n";
+ ss <<" rlambda = 0;\n";
+ }
+#endif
+#ifdef ISNAN
+ if(tmpCur2->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR2= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur2);
+ ss<< " int buffer_kum_len = "<< tmpCurDVR2->GetArrayLength();
+ ss<< ";\n";
+ ss <<" if(gid0 >= buffer_kum_len || isNan(";
+ ss <<vSubArguments[2]->GenSlidingWindowDeclRef();
+ ss <<"))\n";
+ ss <<" rkum = 0;\n";
+ }
+#endif
+ ss <<" if(rlambda <= 0.0)\n";
+ ss <<" {\n";
+ ss <<" tmp = -DBL_MAX;\n";
+ ss <<" }\n";
+ ss <<" else if(rkum == 0)\n";
+ ss <<" {\n";
+ ss <<" if(rx >= 0)\n";
+ ss <<" tmp = rlambda*exp(-rlambda*rx);\n";
+ ss <<" else\n";
+ ss <<" tmp = 0.0;\n";
+ ss <<" }\n";
+ ss <<" else\n";
+ ss <<" {\n";
+ ss <<" if(rx > 0)\n";
+ ss <<" tmp = 1.0 - exp(-rlambda*rx);\n";
+ ss <<" else\n";
+ ss <<" tmp = 0.0;\n";
+ ss <<" }\n";
+ ss <<" return tmp;\n";
+ ss <<"}";
+}
void OpFdist::BinInlineFun(std::set<std::string>& decls,
std::set<std::string>& funs)
{
diff --git a/sc/source/core/opencl/op_statistical.hxx b/sc/source/core/opencl/op_statistical.hxx
index 743a4ec..9566d30 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -21,6 +21,13 @@ public:
const std::string sSymName, SubArguments &vSubArguments);
virtual std::string BinFuncName(void) const { return "Standard"; }
};
+class OpExponDist: public Normal
+{
+public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments);
+ virtual std::string BinFuncName(void) const { return "ExponDist"; }
+};
class OpVar: public Normal
{
public:
commit b825d6fd83e6eadd732b930c0aae01f9c50abed8
Author: tianyao <tianyao at multicorewareinc.com>
Date: Sat Nov 9 12:35:40 2013 +0800
GPU Calc: unit test cases for LOG10
Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
AMLOEXT-180 BUG
Change-Id: Ie52bc244f40df8624c49a3a31406cb5be5f04ac4
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/qa/unit/data/ods/opencl/math/log10.ods b/sc/qa/unit/data/ods/opencl/math/log10.ods
new file mode 100644
index 0000000..12058da
Binary files /dev/null and b/sc/qa/unit/data/ods/opencl/math/log10.ods differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index af6c512..d287fd1 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -196,6 +196,7 @@ public:
void testStatisticalFormulaBetaDist();
void testMathFormulaCscH();
void testMathFormulaExp();
+ void testMathFormulaLog10();
CPPUNIT_TEST_SUITE(ScOpenclTest);
CPPUNIT_TEST(testSharedFormulaXLS);
CPPUNIT_TEST(testFinacialFormula);
@@ -323,6 +324,7 @@ public:
CPPUNIT_TEST(testStatisticalFormulaBetaDist);
CPPUNIT_TEST(testMathFormulaCscH);
CPPUNIT_TEST(testMathFormulaExp);
+ CPPUNIT_TEST(testMathFormulaLog10);
CPPUNIT_TEST_SUITE_END();
private:
@@ -3593,6 +3595,28 @@ void ScOpenclTest::testMathFormulaFloor()
xDocSh->DoClose();
xDocShRes->DoClose();
}
+//[AMLOEXT-180]
+void ScOpenclTest::testMathFormulaLog10()
+{
+ if (!detectOpenCLDevice())
+ return;
+ ScDocShellRef xDocSh = loadDoc("opencl/math/log10.", ODS);
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+ enableOpenCL();
+ pDoc->CalcAll();
+ ScDocShellRef xDocShRes = loadDoc("opencl/math/log10.", ODS);
+ ScDocument* pDocRes = xDocShRes->GetDocument();
+ CPPUNIT_ASSERT(pDocRes);
+ for (SCROW i = 0; i <= 15; ++i)
+ {
+ double fLibre = pDoc->GetValue(ScAddress(1,i,0));
+ double fExcel = pDocRes->GetValue(ScAddress(1,i,0));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+ }
+ xDocSh->DoClose();
+ xDocShRes->DoClose();
+}
ScOpenclTest::ScOpenclTest()
: ScBootstrapFixture( "/sc/qa/unit/data" )
{
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 7762eb8..fa4b856 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1428,6 +1428,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
case ocB:
case ocBetaDist:
case ocExp:
+ case ocLog10:
// Don't change the state.
break;
default:
commit 3fa3072bfaeeae1145967432a7d809a0925dd064
Author: tianyao <tianyao at multicorewareinc.com>
Date: Sat Nov 9 12:59:19 2013 +0800
GPU Calc: implemented LOG10
AMLOEXT-180 FIX
Change-Id: I5e3be337e5ebd44f0aa93ce26ab01cc158c2a758
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 9eeafb7..13f9050 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1264,6 +1264,9 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
case ocExp:
mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], new OpExp));
break;
+ case ocLog10:
+ mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], new OpLog10));
+ break;
case ocExternal:
if ( !(pChild->GetExternal().compareTo(OUString(
"com.sun.star.sheet.addin.Analysis.getEffect"))))
diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx
index 9934014..9addfe3 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -288,6 +288,36 @@ void OpExp::GenSlidingWindowFunction(std::stringstream &ss,
ss << "return tmp;\n";
ss << "}";
}
+
+void OpLog10::GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments)
+{
+ FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
+ const formula::SingleVectorRefToken*tmpCurDVR= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur);
+ ss << "\ndouble " << sSymName;
+ ss << "_"<< BinFuncName() <<"(";
+ for (unsigned i = 0; i < vSubArguments.size(); i++)
+ {
+ if (i)
+ ss << ",";
+ vSubArguments[i]->GenSlidingWindowDecl(ss);
+ }
+ ss << ")\n{\n\t";
+ ss <<"int gid0=get_global_id(0);\n\t";
+ ss << "double arg0 = " << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ";\n\t";
+#ifdef ISNAN
+ ss<< "if(isNan(arg0)||(gid0>=";
+ ss<<tmpCurDVR->GetArrayLength();
+ ss<<"))\n\t\t";
+ ss<<"arg0 = 0;\n\t";
+#endif
+ ss << "double tmp=log10(arg0);\n\t";
+ ss << "return tmp;\n";
+ ss << "}";
+}
+
void OpSinh::GenSlidingWindowFunction(std::stringstream &ss,
const std::string sSymName, SubArguments &vSubArguments)
{
diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx
index 247800e..ea96db8 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -218,6 +218,13 @@ public:
const std::string sSymName, SubArguments &vSubArguments);
virtual std::string BinFuncName(void) const { return "Exp"; }
};
+class OpLog10: public Normal
+{
+public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments);
+ virtual std::string BinFuncName(void) const { return "Log10"; }
+};
}}
#endif
commit 349d7cf756967abb5a29f2f891961cc0911f7666
Author: tianyao <tianyao at multicorewareinc.com>
Date: Sat Nov 9 12:19:24 2013 +0800
GPU Calc: unit test cases for EXP
Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
AMLOEXT-165 BUG
Change-Id: If3661eaa7938d383c239a5978f748015d6f021a4
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/qa/unit/data/ods/opencl/math/exp.ods b/sc/qa/unit/data/ods/opencl/math/exp.ods
new file mode 100644
index 0000000..2710fb8
Binary files /dev/null and b/sc/qa/unit/data/ods/opencl/math/exp.ods differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 3412552..af6c512 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -195,6 +195,7 @@ public:
void testStatisticalFormulaB();
void testStatisticalFormulaBetaDist();
void testMathFormulaCscH();
+ void testMathFormulaExp();
CPPUNIT_TEST_SUITE(ScOpenclTest);
CPPUNIT_TEST(testSharedFormulaXLS);
CPPUNIT_TEST(testFinacialFormula);
@@ -321,6 +322,7 @@ public:
CPPUNIT_TEST(testStatisticalFormulaB);
CPPUNIT_TEST(testStatisticalFormulaBetaDist);
CPPUNIT_TEST(testMathFormulaCscH);
+ CPPUNIT_TEST(testMathFormulaExp);
CPPUNIT_TEST_SUITE_END();
private:
@@ -3524,6 +3526,28 @@ void ScOpenclTest::testStatisticalFormulaBetaDist()
xDocSh->DoClose();
xDocShRes->DoClose();
}
+//[AMLOEXT-165]
+void ScOpenclTest::testMathFormulaExp()
+{
+ if (!detectOpenCLDevice())
+ return;
+ ScDocShellRef xDocSh = loadDoc("opencl/math/exp.", ODS);
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+ enableOpenCL();
+ pDoc->CalcAll();
+ ScDocShellRef xDocShRes = loadDoc("opencl/math/exp.", ODS);
+ ScDocument* pDocRes = xDocShRes->GetDocument();
+ CPPUNIT_ASSERT(pDocRes);
+ for (SCROW i = 0; i <= 15; ++i)
+ {
+ double fLibre = pDoc->GetValue(ScAddress(1,i,0));
+ double fExcel = pDocRes->GetValue(ScAddress(1,i,0));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+ }
+ xDocSh->DoClose();
+ xDocShRes->DoClose();
+}
//[AMLOEXT-166]
void ScOpenclTest::testStatisticalFormulaChiDist()
{
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 6e1a606..7762eb8 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1427,6 +1427,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
case ocFTest:
case ocB:
case ocBetaDist:
+ case ocExp:
// Don't change the state.
break;
default:
commit 7ccd1f328b95a42f2b6d9ea43c6b8bf4aaa25233
Author: tianyao <tianyao at multicorewareinc.com>
Date: Sat Nov 9 12:25:38 2013 +0800
GPU Calc: implemented EXP
AMLOEXT-165 FIX
Change-Id: I73693ecab752d48f620bc0cd53e29d9a8fe16c93
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 5b5cd47..9eeafb7 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1261,6 +1261,9 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpCscH));
break;
+ case ocExp:
+ mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], new OpExp));
+ break;
case ocExternal:
if ( !(pChild->GetExternal().compareTo(OUString(
"com.sun.star.sheet.addin.Analysis.getEffect"))))
diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx
index 5b6857b..9934014 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -260,6 +260,34 @@ void OpCscH::GenSlidingWindowFunction(
ss << "return tmp;\n";
ss << "}";
}
+void OpExp::GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments)
+{
+ FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
+ const formula::SingleVectorRefToken*tmpCurDVR= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur);
+ ss << "\ndouble " << sSymName;
+ ss << "_"<< BinFuncName() <<"(";
+ for (unsigned i = 0; i < vSubArguments.size(); i++)
+ {
+ if (i)
+ ss << ",";
+ vSubArguments[i]->GenSlidingWindowDecl(ss);
+ }
+ ss << ")\n{\n\t";
+ ss <<"int gid0=get_global_id(0);\n\t";
+ ss << "double arg0 = " << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ";\n\t";
+#ifdef ISNAN
+ ss<< "if(isNan(arg0)||(gid0>=";
+ ss<<tmpCurDVR->GetArrayLength();
+ ss<<"))\n\t\t";
+ ss<<"arg0 = 0;\n\t";
+#endif
+ ss << "double tmp=exp(arg0);\n\t";
+ ss << "return tmp;\n";
+ ss << "}";
+}
void OpSinh::GenSlidingWindowFunction(std::stringstream &ss,
const std::string sSymName, SubArguments &vSubArguments)
{
diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx
index 0772245..247800e 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -211,6 +211,13 @@ public:
const std::string sSymName, SubArguments &vSubArguments);
virtual std::string BinFuncName(void) const { return "CscH"; }
};
+class OpExp: public Normal
+{
+public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments);
+ virtual std::string BinFuncName(void) const { return "Exp"; }
+};
}}
#endif
commit 2a3225899e8d98410d5f47c59aa4cd6fe911b9f6
Author: tianyao <tianyao at multicorewareinc.com>
Date: Sat Nov 9 12:04:30 2013 +0800
GPU Calc: unit test cases for CSCH
Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
AMLOEXT-106 BUG
Change-Id: Ic20019c3f8f823bc9107c42d2e5f27eff6418a3a
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/qa/unit/data/ods/opencl/math/csch.ods b/sc/qa/unit/data/ods/opencl/math/csch.ods
new file mode 100644
index 0000000..5a29cdc
Binary files /dev/null and b/sc/qa/unit/data/ods/opencl/math/csch.ods differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index d3c073d..3412552 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -194,6 +194,7 @@ public:
void testStatisticalFormulaFTest();
void testStatisticalFormulaB();
void testStatisticalFormulaBetaDist();
+ void testMathFormulaCscH();
CPPUNIT_TEST_SUITE(ScOpenclTest);
CPPUNIT_TEST(testSharedFormulaXLS);
CPPUNIT_TEST(testFinacialFormula);
@@ -319,6 +320,7 @@ public:
CPPUNIT_TEST(testStatisticalFormulaFTest);
CPPUNIT_TEST(testStatisticalFormulaB);
CPPUNIT_TEST(testStatisticalFormulaBetaDist);
+ CPPUNIT_TEST(testMathFormulaCscH);
CPPUNIT_TEST_SUITE_END();
private:
@@ -2048,6 +2050,28 @@ void ScOpenclTest::testStatisticalFormulaPhi()
xDocSh->DoClose();
xDocShRes->DoClose();
}
+//[AMLOEXT-106]
+void ScOpenclTest::testMathFormulaCscH()
+{
+ if (!detectOpenCLDevice())
+ return;
+ ScDocShellRef xDocSh = loadDoc("opencl/math/csch.", ODS);
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+ enableOpenCL();
+ pDoc->CalcAll();
+ ScDocShellRef xDocShRes = loadDoc("opencl/math/csch.", ODS);
+ ScDocument* pDocRes = xDocShRes->GetDocument();
+ CPPUNIT_ASSERT(pDocRes);
+ for (SCROW i = 0; i <= 15; ++i)
+ {
+ double fLibre = pDoc->GetValue(ScAddress(1,i,0));
+ double fExcel = pDocRes->GetValue(ScAddress(1,i,0));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+ }
+ xDocSh->DoClose();
+ xDocShRes->DoClose();
+}
//[AMLOEXT-107]
void ScOpenclTest::testStatisticalFormulaLogInv()
{
commit 02d28b8cca5f4ed635b003bce75d37bff18eed3a
Author: tianyao <tianyao at multicorewareinc.com>
Date: Sat Nov 9 12:08:15 2013 +0800
GPU Calc: implemented CSCH
AMLOEXT-106 FIX
Change-Id: Ib03ddf99705424001971c5080baf998236b2e48e
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index e25ce6b..5b5cd47 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1257,6 +1257,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpBetaDist));
break;
+ case ocCosecantHyp:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpCscH));
+ break;
case ocExternal:
if ( !(pChild->GetExternal().compareTo(OUString(
"com.sun.star.sheet.addin.Analysis.getEffect"))))
diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx
index ab556d9..5b6857b 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -232,6 +232,34 @@ void OpSumIfs::GenSlidingWindowFunction(std::stringstream &ss,
ss << "return tmp;\n";
ss << "}";
}
+void OpCscH::GenSlidingWindowFunction(
+ std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments)
+{
+ FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
+ const formula::SingleVectorRefToken*tmpCurDVR= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur);
+ ss << "\ndouble " << sSymName;
+ ss << "_"<< BinFuncName() <<"(";
+ for (unsigned i = 0; i < vSubArguments.size(); i++)
+ {
+ if (i)
+ ss << ",";
+ vSubArguments[i]->GenSlidingWindowDecl(ss);
+ }
+ ss << ")\n{\n\t";
+ ss <<"int gid0=get_global_id(0);\n\t";
+ ss << "double arg0 = " << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ";\n\t";
+#ifdef ISNAN
+ ss<< "if(isNan(arg0)||(gid0>=";
+ ss<<tmpCurDVR->GetArrayLength();
+ ss<<"))\n\t\t";
+ ss<<"arg0 = 0;\n\t";
+#endif
+ ss << "double tmp=1/sinh(arg0);\n\t";
+ ss << "return tmp;\n";
+ ss << "}";
+}
void OpSinh::GenSlidingWindowFunction(std::stringstream &ss,
const std::string sSymName, SubArguments &vSubArguments)
{
diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx
index 22f70c9..0772245 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -204,6 +204,13 @@ public:
const std::string sSymName, SubArguments &vSubArguments);
virtual std::string BinFuncName(void) const { return "Floor"; }
};
+class OpCscH: public Normal
+{
+public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments);
+ virtual std::string BinFuncName(void) const { return "CscH"; }
+};
}}
#endif
commit 52a17171d45ce25177277a569e78ee9318f705bf
Author: mingli <mingli at multicorewareinc.com>
Date: Sat Nov 9 11:49:52 2013 +0800
GPU Calc: unit test cases for BETADIST
Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
AMLOEXT-162 BUG
Change-Id: I7d0300030d7518d20dd7b890dc665e9b56ba5c8d
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/qa/unit/data/ods/opencl/statistical/BetaDist.ods b/sc/qa/unit/data/ods/opencl/statistical/BetaDist.ods
new file mode 100644
index 0000000..197ea5a
Binary files /dev/null and b/sc/qa/unit/data/ods/opencl/statistical/BetaDist.ods differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index d1aa95c..d3c073d 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -193,6 +193,7 @@ public:
void testStatisticalFormulaFInv();
void testStatisticalFormulaFTest();
void testStatisticalFormulaB();
+ void testStatisticalFormulaBetaDist();
CPPUNIT_TEST_SUITE(ScOpenclTest);
CPPUNIT_TEST(testSharedFormulaXLS);
CPPUNIT_TEST(testFinacialFormula);
@@ -317,6 +318,7 @@ public:
CPPUNIT_TEST(testStatisticalFormulaFInv);
CPPUNIT_TEST(testStatisticalFormulaFTest);
CPPUNIT_TEST(testStatisticalFormulaB);
+ CPPUNIT_TEST(testStatisticalFormulaBetaDist);
CPPUNIT_TEST_SUITE_END();
private:
@@ -3472,6 +3474,32 @@ void ScOpenclTest::testStatisticalFormulaB()
xDocSh->DoClose();
xDocShRes->DoClose();
}
+//[AMLOEXT-162]
+void ScOpenclTest::testStatisticalFormulaBetaDist()
+{
+ if (!detectOpenCLDevice())
+ return;
+ ScDocShellRef xDocSh = loadDoc("opencl/statistical/BetaDist.", ODS);
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+ enableOpenCL();
+ pDoc->CalcAll();
+ ScDocShellRef xDocShRes = loadDoc("opencl/statistical/BetaDist.", ODS);
+ ScDocument* pDocRes = xDocShRes->GetDocument();
+ CPPUNIT_ASSERT(pDocRes);
+ // Check the results of formula cells in the shared formula range.
+ for (SCROW i = 1; i <= 19; ++i)
+ {
+ double fLibre = pDoc->GetValue(ScAddress(6,i,0));
+ double fExcel = pDocRes->GetValue(ScAddress(6,i,0));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+ fLibre = pDoc->GetValue(ScAddress(7,i,0));
+ fExcel = pDocRes->GetValue(ScAddress(7,i,0));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+ }
+ xDocSh->DoClose();
+ xDocShRes->DoClose();
+}
//[AMLOEXT-166]
void ScOpenclTest::testStatisticalFormulaChiDist()
{
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index b1b1de3..6e1a606 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1426,6 +1426,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
case ocFInv:
case ocFTest:
case ocB:
+ case ocBetaDist:
// Don't change the state.
break;
default:
commit 8d7b2d96e5a8d1f991476dfdc6f940bd8adf0ed4
Author: mingli <mingli at multicorewareinc.com>
Date: Sat Nov 9 11:52:51 2013 +0800
GPU Calc: implemented BETADIST
AMLOEXT-162 FIX
Change-Id: I3ecd4e81f34e2dd01e924acb153de91b2f076bac
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index d02b137..e25ce6b 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1253,6 +1253,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpB));
break;
+ case ocBetaDist:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpBetaDist));
+ 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 247d61c..e30b4d9 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -3730,6 +3730,142 @@ void OpB::GenSlidingWindowFunction(std::stringstream &ss,
" return tmp;"
"}\n";
}
+void OpBetaDist::BinInlineFun(std::set<std::string>& decls,
+ std::set<std::string>& funs)
+{
+ decls.insert(fMachEpsDecl);decls.insert(fMaxGammaArgumentDecl);
+ decls.insert(GetBetaDistDecl);decls.insert(GetBetaDistPDFDecl);
+ decls.insert(lcl_GetBetaHelperContFracDecl);decls.insert(GetLogBetaDecl);
+ decls.insert(GetBetaDecl);decls.insert(lcl_getLanczosSumDecl);
+ funs.insert(GetBetaDist);funs.insert(GetBetaDistPDF);
+ funs.insert(lcl_GetBetaHelperContFrac);funs.insert(GetLogBeta);
+ funs.insert(GetBeta);funs.insert(lcl_getLanczosSum);
+}
+
+void OpBetaDist::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 << " double tmp;\n";
+ ss << " double arg0,arg1,arg2,arg3,arg4,arg5;\n";
+ size_t i = vSubArguments.size();
+ size_t nItems = 0;
+ for (i = 0; i < vSubArguments.size(); i++)
+ {
+ FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
+ assert(pCur);
+ if (pCur->GetType() == formula::svDoubleVectorRef)
+ {
+ const formula::DoubleVectorRefToken* pDVR =
+ dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
+ size_t nCurWindowSize = pDVR->GetRefRowSize();
+ ss << "for (int i = ";
+ if (!pDVR->IsStartFixed() && pDVR->IsEndFixed()) {
+#ifdef ISNAN
+ ss << "gid0; i < " << pDVR->GetArrayLength();
+ ss << " && i < " << nCurWindowSize << "; i++){\n";
+#else
+ ss << "gid0; i < "<< nCurWindowSize << "; i++)\n";
+#endif
+ } else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed()) {
+#ifdef ISNAN
+ ss << "0; i < " << pDVR->GetArrayLength();
+ ss << " && i < gid0+"<< nCurWindowSize << "; i++){\n";
+#else
+ ss << "0; i < gid0+"<< nCurWindowSize << "; i++)\n ";
+#endif
+ } else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed()){
+#ifdef ISNAN
+ ss << "0; i + gid0 < " << pDVR->GetArrayLength();
+ ss << " && i < "<< nCurWindowSize << "; i++){\n ";
+#else
+ ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+#endif
+ }
+ else {
+#ifdef ISNAN
+ ss << "0; i < "<< nCurWindowSize << "; i++){\n";
+#else
+ ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+#endif
+ }
+ nItems += nCurWindowSize;
+ }
+ else if (pCur->GetType() == formula::svSingleVectorRef)
+ {
+#ifdef ISNAN
+ const formula::SingleVectorRefToken* pSVR =
+ dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
+ ss << " if (gid0 < " << pSVR->GetArrayLength() << ")\n";
+ ss << " {\n";
+ ss << " if (isNan(";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << "))\n";
+ ss << " arg"<<i<<"= 0;\n";
+ ss << " else\n";
+ ss << " arg"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+ ss << " }\n";
+ ss << " else\n";
+ ss << " arg"<<i<<"= 0;\n";
+#endif
+ }
+ else if (pCur->GetType() == formula::svDouble)
+ {
+#ifdef ISNAN
+ ss << " if (isNan(";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << "))\n";
+ ss << " arg"<<i<<"= 0;\n";
+ ss << " else\n";
+ ss << " arg"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+#endif
+ }
+ }
+ ss << " double fScale = arg4 - arg3;\n"
+ " if (fScale <= 0.0 || arg1 <= 0.0 || arg2 <= 0.0)\n"
+ " {\n"
+ " tmp = DBL_MIN;\n"
+ " return tmp;\n"
+ " }\n"
+ " if (arg5)\n"
+ " {\n"
+ " if (arg0< arg3)\n"
+ " {\n"
+ " tmp = 0.0;\n"
+ " return tmp;\n"
+ " }\n"
+ " if (arg0 > arg4)\n"
+ " {\n"
+ " tmp = 1.0;\n"
+ " return tmp;\n"
+ " }\n"
+ " arg0 = (arg0-arg3)/fScale;\n"
+ " tmp = GetBetaDist(arg0, arg1, arg2);\n"
+ " }\n"
+ " else\n"
+ " {\n"
+ " if (arg0 < arg3 || arg0 > arg4 )\n"
+ " {\n"
+ " tmp = 0.0;\n"
+ " return tmp;\n"
+ " }\n"
+ " arg0 = (arg0 - arg3)/fScale;\n"
+ " tmp = GetBetaDistPDF(arg0, arg1, arg2)/fScale;\n"
+ " }\n";
+ ss << " return tmp;\n";
+ ss << "}\n";
+}
}}
diff --git a/sc/source/core/opencl/op_statistical.hxx b/sc/source/core/opencl/op_statistical.hxx
index fa2880d..743a4ec 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -306,6 +306,15 @@ public:
);
virtual std::string BinFuncName(void) const { return "B"; }
};
+class OpBetaDist: public Normal
+{
+public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments);
+ void BinInlineFun(std::set<std::string>& decls,std::set<std::string>& funs
+);
+ virtual std::string BinFuncName(void) const { return "BetaDist"; }
+};
}}
commit 58d21c5cae73893a04a51f3f271bfe7f923b1c3d
Author: mingli <mingli at multicorewareinc.com>
Date: Sat Nov 9 11:30:13 2013 +0800
GPU Calc: unit test cases for B
Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
AMLOEXT-161 BUG
Change-Id: Ie40900785702c20b45dc6c60600d11822d46c2e6
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/qa/unit/data/xls/opencl/statistical/B.xls b/sc/qa/unit/data/xls/opencl/statistical/B.xls
new file mode 100644
index 0000000..06952c4
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/statistical/B.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index b597ed0..d1aa95c 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -192,6 +192,7 @@ public:
void testMathFormulaFloor();
void testStatisticalFormulaFInv();
void testStatisticalFormulaFTest();
+ void testStatisticalFormulaB();
CPPUNIT_TEST_SUITE(ScOpenclTest);
CPPUNIT_TEST(testSharedFormulaXLS);
CPPUNIT_TEST(testFinacialFormula);
@@ -315,6 +316,7 @@ public:
CPPUNIT_TEST(testMathFormulaFloor);
CPPUNIT_TEST(testStatisticalFormulaFInv);
CPPUNIT_TEST(testStatisticalFormulaFTest);
+ CPPUNIT_TEST(testStatisticalFormulaB);
CPPUNIT_TEST_SUITE_END();
private:
@@ -3444,6 +3446,32 @@ void ScOpenclTest::testStatisticalFormulaFTest()
xDocSh->DoClose();
xDocShRes->DoClose();
}
+//[AMLOEXT-161]
+void ScOpenclTest::testStatisticalFormulaB()
+{
+ if (!detectOpenCLDevice())
+ return;
+ ScDocShellRef xDocSh = loadDoc("opencl/statistical/B.", XLS);
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+ enableOpenCL();
+ pDoc->CalcAll();
+ ScDocShellRef xDocShRes = loadDoc("opencl/statistical/B.", XLS);
+ ScDocument* pDocRes = xDocShRes->GetDocument();
+ CPPUNIT_ASSERT(pDocRes);
+ // Check the results of formula cells in the shared formula range.
+ for (SCROW i = 1; i <= 19; ++i)
+ {
+ double fLibre = pDoc->GetValue(ScAddress(4,i,0));
+ double fExcel = pDocRes->GetValue(ScAddress(4,i,0));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+ fLibre = pDoc->GetValue(ScAddress(5,i,0));
+ fExcel = pDocRes->GetValue(ScAddress(5,i,0));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+ }
+ xDocSh->DoClose();
+ xDocShRes->DoClose();
+}
//[AMLOEXT-166]
void ScOpenclTest::testStatisticalFormulaChiDist()
{
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index c0bb7fd..b1b1de3 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1425,6 +1425,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
case ocFloor:
case ocFInv:
case ocFTest:
+ case ocB:
// Don't change the state.
break;
default:
commit 2b183e296940f19bb195ba967e09589d60f7cf40
Author: mingli <mingli at multicorewareinc.com>
Date: Sat Nov 9 11:32:43 2013 +0800
GPU Calc: implemented B
AMLOEXT-161 FIX
Change-Id: Id383ee83028dac4e6d5a4341da8d80a1f46874ec
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 6fd4f22..d02b137 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1249,6 +1249,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpFTest));
break;
+ case ocB:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpB));
+ 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 e0af4c6..247d61c 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -3573,7 +3573,163 @@ void OpFTest::GenSlidingWindowFunction(std::stringstream &ss,
ss << " return tmp;\n";
ss << "}";
}
+void OpB::BinInlineFun(std::set<std::string>& decls,
+ std::set<std::string>& funs)
+{
+ //decls.insert(fBigInvDecl);decls.insert(fLogDblMaxDecl);
+ decls.insert(GetBinomDistPMFDecl);decls.insert(MinDecl);
+ decls.insert(fMachEpsDecl);decls.insert(fMaxGammaArgumentDecl);
+ decls.insert(GetBetaDistDecl);decls.insert(GetBetaDistPDFDecl);
+ decls.insert(lcl_GetBetaHelperContFracDecl);decls.insert(GetLogBetaDecl);
+ decls.insert(lcl_getLanczosSumDecl); decls.insert(GetBetaDecl);
+ funs.insert(GetBinomDistPMF);funs.insert(lcl_GetBinomDistRange);
+ funs.insert(GetBetaDist);funs.insert(GetBetaDistPDF);
+ funs.insert(lcl_GetBetaHelperContFrac);funs.insert(GetLogBeta);
+ funs.insert(lcl_getLanczosSum);funs.insert(GetBeta);
+}
+void OpB::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 << " double min = 2.22507e-308;\n";
+ ss << " double tmp;\n";
+ ss << " double arg0,arg1,arg2,arg3;\n";
+ size_t i = vSubArguments.size();
+ size_t nItems = 0;
+ for (i = 0; i < vSubArguments.size(); i++)
+ {
+ FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
+ assert(pCur);
+ if (pCur->GetType() == formula::svDoubleVectorRef)
+ {
+ const formula::DoubleVectorRefToken* pDVR =
+ dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
+ size_t nCurWindowSize = pDVR->GetRefRowSize();
+ ss << "for (int i = ";
+ if (!pDVR->IsStartFixed() && pDVR->IsEndFixed()) {
+#ifdef ISNAN
+ ss << "gid0; i < " << pDVR->GetArrayLength();
+ ss << " && i < " << nCurWindowSize << "; i++){\n";
+#else
+ ss << "gid0; i < "<< nCurWindowSize << "; i++)\n";
+#endif
+ } else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed()) {
+#ifdef ISNAN
+ ss << "0; i < " << pDVR->GetArrayLength();
+ ss << " && i < gid0+"<< nCurWindowSize << "; i++){\n";
+#else
+ ss << "0; i < gid0+"<< nCurWindowSize << "; i++)\n ";
+#endif
+ } else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed()){
+#ifdef ISNAN
+ ss << "0; i + gid0 < " << pDVR->GetArrayLength();
+ ss << " && i < "<< nCurWindowSize << "; i++){\n ";
+#else
+ ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+#endif
+ }
+ else {
+#ifdef ISNAN
+ ss << "0; i < "<< nCurWindowSize << "; i++){\n";
+#else
+ ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+#endif
+ }
+ nItems += nCurWindowSize;
+ }
+ else if (pCur->GetType() == formula::svSingleVectorRef)
+ {
+#ifdef ISNAN
+ const formula::SingleVectorRefToken* pSVR =
+ dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
+ ss << " if (gid0 < " << pSVR->GetArrayLength() << ")\n";
+ ss << " {\n";
+ ss << " if (isNan(";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << "))\n";
+ ss << " arg"<<i<<"= 0;\n";
+ ss << " else\n";
+ ss << " arg"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+ ss << " }\n";
+ ss << " else\n";
+ ss << " arg"<<i<<"= 0;\n";
+#endif
+ }
+ else if (pCur->GetType() == formula::svDouble)
+ {
+#ifdef ISNAN
+ ss << " if (isNan(";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << "))\n";
+ ss << " arg"<<i<<"= 0;\n";
+ ss << " else\n";
+ ss << " arg"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+#endif
+ }
+ }
+ ss << " double rxs = floor(arg2);\n"
+ " double rxe = floor(arg3);\n"
+ " double rn = floor(arg0);\n"
+ " double rq = (0.5 - arg1) + 0.5;\n"
+ " bool bIsValidX = (0.0 <= rxs && rxs <= rxe && rxe <= rn);\n"
+ " if (bIsValidX && 0.0 < arg1 && arg1 < 1.0)\n"
+ " {\n"
+ " if (rxs == rxe)\n"
+ " tmp = GetBinomDistPMF(rxs, rn, arg1);\n"
+ " else\n"
+ " {\n"
+ " double fFactor = pow(rq, rn);\n"
+ " if (fFactor > min)\n"
+ " tmp ="
+ " lcl_GetBinomDistRange(rn, rxs, rxe, fFactor, arg1, rq);\n"
+ " else\n"
+ " {\n"
+ " fFactor = pow(arg1, rn);\n"
+ " if (fFactor > min)\n"
+ " {\n"
+ " tmp ="
+ "lcl_GetBinomDistRange(rn, rn - rxe, rn - rxs, fFactor, rq, arg1);\n"
+ " }\n"
+ " else\n"
+ " tmp ="
+ "GetBetaDist(rq, rn - rxe, rxe + 1.0)"
+ "- GetBetaDist(rq, rn - rxs + 1, rxs);\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " else\n"
+ " {\n"
+ " if (bIsValidX)\n"
+ " {\n"
+ " if (arg1 == 0.0)\n"
+ " tmp = (rxs == 0.0 ? 1.0 : 0.0);\n"
+ " else if (arg1 == 1.0)\n"
+ " tmp = (rxe == rn ? 1.0 : 0.0);\n"
+ " else\n"
+ " {\n"
+ " tmp = DBL_MIN;\n"
+ " }\n"
+ " }\n"
+ " else\n"
+ " {\n"
+ " tmp = DBL_MIN;\n"
+ " }\n"
+ " }\n"
+ " return tmp;"
+ "}\n";
+}
}}
diff --git a/sc/source/core/opencl/op_statistical.hxx b/sc/source/core/opencl/op_statistical.hxx
index 63c6a79..fa2880d 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -297,6 +297,15 @@ public:
);
virtual std::string BinFuncName(void) const { return "FTest"; }
};
+class OpB: public Normal
+{
+public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments);
+ void BinInlineFun(std::set<std::string>& decls,std::set<std::string>& funs
+);
+ virtual std::string BinFuncName(void) const { return "B"; }
+};
}}
commit b9e443d58d0f915b8dacd7466c2072c270af401a
Author: mingli <mingli at multicorewareinc.com>
Date: Sat Nov 9 11:19:35 2013 +0800
GPU Calc: unit test cases for FTEST
Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
AMLOEXT-160 BUG
Change-Id: I248b3e71e16abe04585abfc7736c02786b2b871a
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/qa/unit/data/xls/opencl/statistical/FTest.xls b/sc/qa/unit/data/xls/opencl/statistical/FTest.xls
new file mode 100644
index 0000000..088cb6d
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/statistical/FTest.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 444f853..b597ed0 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -191,6 +191,7 @@ public:
void testStatisticalFormulaGammaInv();
void testMathFormulaFloor();
void testStatisticalFormulaFInv();
+ void testStatisticalFormulaFTest();
CPPUNIT_TEST_SUITE(ScOpenclTest);
CPPUNIT_TEST(testSharedFormulaXLS);
CPPUNIT_TEST(testFinacialFormula);
@@ -313,6 +314,7 @@ public:
CPPUNIT_TEST(testStatisticalFormulaGammaInv);
CPPUNIT_TEST(testMathFormulaFloor);
CPPUNIT_TEST(testStatisticalFormulaFInv);
+ CPPUNIT_TEST(testStatisticalFormulaFTest);
CPPUNIT_TEST_SUITE_END();
private:
@@ -3418,6 +3420,30 @@ void ScOpenclTest::testStatisticalFormulaFInv()
xDocSh->DoClose();
xDocShRes->DoClose();
}
+//[AMLOEXT-160]
+void ScOpenclTest::testStatisticalFormulaFTest()
+{
+ if (!detectOpenCLDevice())
+ return;
+
+ ScDocShellRef xDocSh = loadDoc("opencl/statistical/FTest.", XLS);
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+ enableOpenCL();
+ pDoc->CalcAll();
+ ScDocShellRef xDocShRes = loadDoc("opencl/statistical/FTest.", XLS);
+ ScDocument* pDocRes = xDocShRes->GetDocument();
+ CPPUNIT_ASSERT(pDocRes);
+ // Check the results of formula cells in the shared formula range.
+ for (SCROW i = 1; i <= 19; ++i)
+ {
+ double fLibre = pDoc->GetValue(ScAddress(2,i,0));
+ double fExcel = pDocRes->GetValue(ScAddress(2,i,0));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+ }
+ xDocSh->DoClose();
+ xDocShRes->DoClose();
+}
//[AMLOEXT-166]
void ScOpenclTest::testStatisticalFormulaChiDist()
{
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 165b2f0..c0bb7fd 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1424,6 +1424,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
case ocGammaInv:
case ocFloor:
case ocFInv:
+ case ocFTest:
// Don't change the state.
break;
default:
commit c07c6bde40da1c7817b7bfcb1e888e8b561a184c
Author: mingli <mingli at multicorewareinc.com>
Date: Sat Nov 9 11:25:07 2013 +0800
GPU Calc: implemented FTEST
AMLOEXT-160 FIX
Change-Id: Id97578b33b14a3d2ade021a8bb311c59fe99722f
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 00b9124..6fd4f22 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1245,6 +1245,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpFInv));
break;
+ case ocFTest:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpFTest));
+ 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 3d8aa2e..e0af4c6 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -3466,6 +3466,113 @@ void OpFInv::GenSlidingWindowFunction(std::stringstream &ss,
" return tmp;"
"}";
}
+void OpFTest::BinInlineFun(std::set<std::string>& decls,
+ std::set<std::string>& funs)
+{
+ decls.insert(fMachEpsDecl);decls.insert(fMaxGammaArgumentDecl);
+ decls.insert(lcl_getLanczosSumDecl);decls.insert(GetBetaDecl);
+ decls.insert(GetLogBetaDecl);decls.insert(GetBetaDistPDFDecl);
+ decls.insert(lcl_GetBetaHelperContFracDecl);decls.insert(GetBetaDistDecl);
+ decls.insert(GetFDistDecl);
+ funs.insert(lcl_getLanczosSum);funs.insert(GetBeta);
+ funs.insert(GetLogBeta);funs.insert(GetBetaDistPDF);
+ funs.insert(lcl_GetBetaHelperContFrac);funs.insert(GetBetaDist);
+ funs.insert(GetFDist);
+}
+void OpFTest::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 fSum1 = 0.0;\n";
+ ss << " double fSumSqr1 = 0.0;\n";
+ ss << " double fSum2 = 0.0;\n";
+ ss << " double fSumSqr2 = 0.0;\n";
+ ss << " int length0="<<nCurWindowSize;
+ ss << ";\n";
+ ss << " int length1= "<<nCurWindowSize1;
+ ss << ";\n";
+ ss << " double tmp = 0;\n";
+ for (unsigned i = 0; i < vSubArguments.size(); i++)
+ {
+ FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
+ assert(pCur);
+ if (pCur->GetType() == formula::svDoubleVectorRef)
+ {
+ const formula::DoubleVectorRefToken* pDVR =
+ dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
+ size_t nCurWindowSize = pDVR->GetRefRowSize();
+ ss << " for (int i = ";
+#ifdef ISNAN
+ ss << "0; i < "<< nCurWindowSize << "; i++){\n";
+ ss << " double arg"<<i<<" = ";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+#ifdef ISNAN
+ ss << " if(isNan(arg"<<i<<")||((gid0+i)>=";
+ ss << pDVR->GetArrayLength();
+ ss << "))\n";
+ ss << " {\n";
+ ss << " length"<<i<<"--;\n";
+ ss << " continue;\n";
+ ss << " }\n";
+#endif
+ ss << " fSum"<<i+1<<" += arg"<<i<<";\n";
+ ss << " fSumSqr"<<i+1<<" += arg"<<i;
+ ss << " * arg"<<i<<";\n";
+ ss << " }\n";
+#endif
+ }
+ else if (pCur->GetType() == formula::svSingleVectorRef)
+ {
+#ifdef ISNAN
+ ss << "return HUGE_VAL";
+#endif
+ }
+ else if (pCur->GetType() == formula::svDouble)
+ {
+#ifdef ISNAN
+ ss << "return HUGE_VAL";
+#endif
+ }
+ }
+ ss << " double fS1 = (fSumSqr1-fSum1*fSum1/length0)/(length0-1.0);\n"
+ " double fS2 = (fSumSqr2-fSum2*fSum2/length1)/(length1-1.0);\n"
+ " double fF, fF1, fF2;\n"
+ " if (fS1 > fS2)\n"
+ " {\n"
+ " fF = fS1/fS2;\n"
+ " fF1 = length0-1.0;\n"
+ " fF2 = length1-1.0;\n"
+ " }\n"
+ " else\n"
+ " {\n"
+ " fF = fS2/fS1;\n"
+ " fF1 = length1-1.0;\n"
+ " fF2 = length0-1.0;\n"
+ " }\n"
+ " tmp = 2.0*GetFDist(fF, fF1, fF2);\n";
+ ss << " return tmp;\n";
+ ss << "}";
+}
}}
diff --git a/sc/source/core/opencl/op_statistical.hxx b/sc/source/core/opencl/op_statistical.hxx
index ca8e343..63c6a79 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -288,6 +288,15 @@ public:
);
virtual std::string BinFuncName(void) const { return "FInv"; }
};
+class OpFTest: public Normal
+{
+public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments);
+ void BinInlineFun(std::set<std::string>& decls,std::set<std::string>& funs
+);
+ virtual std::string BinFuncName(void) const { return "FTest"; }
+};
}}
commit 649fa80a1120f09aefe099b2cb2efbbdca8199ed
Author: mingli <mingli at multicorewareinc.com>
Date: Sat Nov 9 11:04:24 2013 +0800
GPU Calc: unit test cases for FINV
Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
AMLOEXT-159 BUG
Change-Id: Id792605d06530087c13d939495cfc8bbf617c625
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/qa/unit/data/xls/opencl/statistical/FInv.xls b/sc/qa/unit/data/xls/opencl/statistical/FInv.xls
new file mode 100644
index 0000000..c569f5f
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/statistical/FInv.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index e754f17..444f853 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -190,6 +190,7 @@ public:
void testStatisticalFormulaChiSqInv();
void testStatisticalFormulaGammaInv();
void testMathFormulaFloor();
+ void testStatisticalFormulaFInv();
CPPUNIT_TEST_SUITE(ScOpenclTest);
CPPUNIT_TEST(testSharedFormulaXLS);
CPPUNIT_TEST(testFinacialFormula);
@@ -311,6 +312,7 @@ public:
CPPUNIT_TEST(testStatisticalFormulaChiSqInv);
CPPUNIT_TEST(testStatisticalFormulaGammaInv);
CPPUNIT_TEST(testMathFormulaFloor);
+ CPPUNIT_TEST(testStatisticalFormulaFInv);
CPPUNIT_TEST_SUITE_END();
private:
@@ -3389,6 +3391,33 @@ void ScOpenclTest::testStatisticalFormulaGammaInv()
xDocSh->DoClose();
xDocShRes->DoClose();
}
+//[AMLOEXT-159]
+void ScOpenclTest::testStatisticalFormulaFInv()
+{
+ if (!detectOpenCLDevice())
+ return;
+
+ ScDocShellRef xDocSh = loadDoc("opencl/statistical/FInv.", XLS);
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+ enableOpenCL();
+ pDoc->CalcAll();
+ ScDocShellRef xDocShRes = loadDoc("opencl/statistical/FInv.", XLS);
+ ScDocument* pDocRes = xDocShRes->GetDocument();
+ CPPUNIT_ASSERT(pDocRes);
+ // Check the results of formula cells in the shared formula range.
+ for (SCROW i = 1; i <= 19; ++i)
+ {
+ double fLibre = pDoc->GetValue(ScAddress(3,i,0));
+ double fExcel = pDocRes->GetValue(ScAddress(3,i,0));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+ fLibre = pDoc->GetValue(ScAddress(4,i,0));
+ fExcel = pDocRes->GetValue(ScAddress(4,i,0));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+ }
+ xDocSh->DoClose();
+ xDocShRes->DoClose();
+}
//[AMLOEXT-166]
void ScOpenclTest::testStatisticalFormulaChiDist()
{
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 3100595..165b2f0 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1423,6 +1423,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
case ocChiSqInv:
case ocGammaInv:
case ocFloor:
+ case ocFInv:
// Don't change the state.
break;
default:
commit 6c006e1c661ba011aa2bb2c9fe753cab85b5b366
Author: mingli <mingli at multicorewareinc.com>
Date: Sat Nov 9 11:08:44 2013 +0800
GPU Calc: implemented FINV
AMLOEXT-159 FIX
Change-Id: Ib15803d87b2f108bc1a9f77eeab908b41e3eb402
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 3f7af72..00b9124 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1241,6 +1241,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpFloor));
break;
+ case ocFInv:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpFInv));
+ 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 c3ffb5e..3d8aa2e 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -3264,6 +3264,208 @@ void OpGammaInv::GenSlidingWindowFunction(std::stringstream &ss,
" }\n"
"}\n";
}
+void OpFInv::BinInlineFun(std::set<std::string>& decls,
+ std::set<std::string>& funs)
+{
+ decls.insert(fMachEpsDecl);decls.insert(fMaxGammaArgumentDecl);
+ decls.insert(lcl_getLanczosSumDecl);decls.insert(GetBetaDecl);
+ decls.insert(GetLogBetaDecl);decls.insert(GetBetaDistPDFDecl);
+ decls.insert(lcl_GetBetaHelperContFracDecl);decls.insert(GetFInvValueDecl);
+ funs.insert(lcl_getLanczosSum);funs.insert(GetBeta);
+ funs.insert(GetLogBeta);funs.insert(GetBetaDistPDF);
+ funs.insert(lcl_GetBetaHelperContFrac);funs.insert(GetFInvValue);
+}
+
+void OpFInv::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 << " double tmp;\n";
+ ss << " double arg0,arg1,arg2;\n";
+ size_t i = vSubArguments.size();
+ size_t nItems = 0;
+ for (i = 0; i < vSubArguments.size(); i++)
+ {
+ FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
+ assert(pCur);
+ if (pCur->GetType() == formula::svDoubleVectorRef)
+ {
+ const formula::DoubleVectorRefToken* pDVR =
+ dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
+ size_t nCurWindowSize = pDVR->GetRefRowSize();
+ ss << "for (int i = ";
+ if (!pDVR->IsStartFixed() && pDVR->IsEndFixed()) {
+#ifdef ISNAN
+ ss << "gid0; i < " << pDVR->GetArrayLength();
+ ss << " && i < " << nCurWindowSize << "; i++){\n";
+#else
+ ss << "gid0; i < "<< nCurWindowSize << "; i++)\n";
+#endif
+ } else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed()) {
+#ifdef ISNAN
+ ss << "0; i < " << pDVR->GetArrayLength();
+ ss << " && i < gid0+"<< nCurWindowSize << "; i++){\n";
+#else
+ ss << "0; i < gid0+"<< nCurWindowSize << "; i++)\n ";
+#endif
+ } else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed()){
+#ifdef ISNAN
+ ss << "0; i + gid0 < " << pDVR->GetArrayLength();
+ ss << " && i < "<< nCurWindowSize << "; i++){\n ";
+#else
+ ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+#endif
+ }
+ else {
+#ifdef ISNAN
+ ss << "0; i < "<< nCurWindowSize << "; i++){\n";
+#else
+ ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+#endif
+ }
+ nItems += nCurWindowSize;
+ }
+ else if (pCur->GetType() == formula::svSingleVectorRef)
+ {
+#ifdef ISNAN
+ const formula::SingleVectorRefToken* pSVR =
+ dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
+ ss << " if (gid0 < " << pSVR->GetArrayLength() << ")\n";
+ ss << " {\n";
+ ss << " if (isNan(";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << "))\n";
+ ss << " arg"<<i<<"= 0;\n";
+ ss << " else\n";
+ ss << " arg"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+ ss << " }\n";
+ ss << " else\n";
+ ss << " arg"<<i<<"= 0;\n";
+#endif
+ }
+ else if (pCur->GetType() == formula::svDouble)
+ {
+#ifdef ISNAN
+ ss << " if (isNan(";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << "))\n";
+ ss << " arg"<<i<<"= 0;\n";
+ ss << " else\n";
+ ss << " arg"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+#endif
+ }
+ }
+ ss << " double fF2=floor(arg2);\n"
+ " double fF1=floor(arg1);\n"
+ " bool bConvError;\n"
+ " double fAx=fF1*0.5;\n"
+ " double fBx=fF1;\n"
+ " bConvError = false;\n"
+ " const double fYEps = 1.0E-307;\n"
+ " const double fXEps = 2.22045e-016;\n"
+ " double fAy = arg0-GetFInvValue(fF1,fF2,fAx);\n"
+ " double fBy = arg0-GetFInvValue(fF1,fF2,fBx);\n"
+ " double fTemp;\n"
+ " unsigned short nCount;\n"
+ " for (nCount = 0; nCount < 1000 && !((fAy < 0.0 && fBy > 0.0)"
+ " || (fAy > 0.0 && fBy < 0.0)); nCount++)\n"
+ " {\n"
+ " if (fabs(fAy) <= fabs(fBy))\n"
+ " {\n"
+ " fTemp = fAx;\n"
+ " fAx += 2.0 * (fAx - fBx);\n"
+ " if (fAx < 0.0)\n"
+ " fAx = 0.0;\n"
+ " fBx = fTemp;\n"
+ " fBy = fAy;\n"
+ " fAy = arg0-GetFInvValue(fF1,fF2,fAx);\n"
+ " }\n"
+ " else\n"
+ " {\n"
+ " fTemp = fBx;\n"
+ " fBx += 2.0 * (fBx - fAx);\n"
+ " fAx = fTemp;\n"
+ " fAy = fBy;\n"
+ " fBy = arg0-GetFInvValue(fF1,fF2,fBx);\n"
+ " }\n"
+ " }\n"
+ " if (fAy == 0.0)\n"
+ " {\n"
+ " tmp = fAx;\n"
+ " return tmp;\n"
+ " }\n"
+ " if (fBy == 0.0)\n"
+ " {\n"
+ " tmp = fBx;\n"
+ " return tmp;\n"
+ " }\n"
+ " if (!((fAy < 0.0 && fBy > 0.0) || (fAy > 0.0 && fBy < 0.0)))\n"
+ " {\n"
+ " bConvError = true;\n"
+ " tmp = 0.0;\n"
+ " return tmp;\n"
+ " }\n"
+ " double fPx = fAx;\n"
+ " double fPy = fAy;\n"
+ " double fQx = fBx;\n"
+ " double fQy = fBy;\n"
+ " double fRx = fAx;\n"
+ " double fRy = fAy;\n"
+ " double fSx = 0.5 * (fAx + fBx);\n"
+ " bool bHasToInterpolate = true;\n"
+ " nCount = 0;\n"
+ " while ( nCount < 500 && fabs(fRy) > fYEps &&"
+ "(fBx-fAx) > fmax( fabs(fAx), fabs(fBx)) * fXEps )\n"
+ " {\n"
+ " if (bHasToInterpolate)\n"
+ " {\n"
+ " if (fPy!=fQy && fQy!=fRy && fRy!=fPy)\n"
+ " {\n"
+ " fSx = fPx * fRy * fQy / (fRy-fPy) / (fQy-fPy)+"
+ " fRx * fQy * fPy"
+ "/ (fQy-fRy) / (fPy-fRy)+ fQx * fPy * fRy / (fPy-fQy) / (fRy-fQy);\n"
+ " bHasToInterpolate = (fAx < fSx) && (fSx < fBx);\n"
+ " }\n"
+ " else\n"
+ " bHasToInterpolate = false;\n"
+ " }\n"
+ " if(!bHasToInterpolate)\n"
+ " {\n"
+ " fSx = 0.5 * (fAx + fBx);\n"
+ " fPx = fAx; fPy = fAy;\n"
+ " fQx = fBx; fQy = fBy;\n"
+ " bHasToInterpolate = true;\n"
+ " }\n"
+ " fPx = fQx; fQx = fRx; fRx = fSx;\n"
+ " fPy = fQy; fQy = fRy;\n"
+ " fRy = arg0-GetFInvValue(fF1,fF2,fSx);\n"
+ " if ((fAy < 0.0 && fRy > 0.0) || (fAy > 0.0 && fRy < 0.0))\n"
+ " {\n"
+ " fBx = fRx; fBy = fRy;\n"
+ " }\n"
+ " else\n"
+ " {\n"
+ " fAx = fRx; fAy = fRy;\n"
+ " }\n"
+ " bHasToInterpolate = bHasToInterpolate && (fabs(fRy)"
+ " * 2.0 <= fabs(fQy));\n"
+ " ++nCount;\n"
+ " }\n"
+ " tmp = fRx;\n"
+ " return tmp;"
+ "}";
+}
}}
diff --git a/sc/source/core/opencl/op_statistical.hxx b/sc/source/core/opencl/op_statistical.hxx
index 153d1e9..ca8e343 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -279,6 +279,15 @@ public:
);
virtual std::string BinFuncName(void) const { return "GammaInv"; }
};
+class OpFInv: public Normal
+{
+public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments);
+ void BinInlineFun(std::set<std::string>& decls,std::set<std::string>& funs
+);
+ virtual std::string BinFuncName(void) const { return "FInv"; }
+};
}}
commit a8bb0352b519b37c698ee62ae785523d6bf573a1
Author: dechuang <dechuang at multicorewareinc.com>
Date: Sat Nov 9 10:47:36 2013 +0800
GPU Calc: unit test cases for FLOOR
Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
AMLOEXT-169 BUG
Change-Id: Ib678abfdabd914eb89c712bb14fe7651c3004531
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/qa/unit/data/ods/opencl/math/floor.ods b/sc/qa/unit/data/ods/opencl/math/floor.ods
new file mode 100644
index 0000000..6534ea3
Binary files /dev/null and b/sc/qa/unit/data/ods/opencl/math/floor.ods differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index e8f5509..e754f17 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -189,6 +189,7 @@ public:
void testStatisticalFormulaChiSqDist();
void testStatisticalFormulaChiSqInv();
void testStatisticalFormulaGammaInv();
+ void testMathFormulaFloor();
CPPUNIT_TEST_SUITE(ScOpenclTest);
CPPUNIT_TEST(testSharedFormulaXLS);
CPPUNIT_TEST(testFinacialFormula);
@@ -309,6 +310,7 @@ public:
CPPUNIT_TEST(testStatisticalFormulaChiSqDist);
CPPUNIT_TEST(testStatisticalFormulaChiSqInv);
CPPUNIT_TEST(testStatisticalFormulaGammaInv);
+ CPPUNIT_TEST(testMathFormulaFloor);
CPPUNIT_TEST_SUITE_END();
private:
@@ -3410,6 +3412,28 @@ void ScOpenclTest::testStatisticalFormulaChiDist()
xDocSh->DoClose();
xDocShRes->DoClose();
}
+//[AMLOEXT-169]
+void ScOpenclTest::testMathFormulaFloor()
+{
+ if (!detectOpenCLDevice())
+ return;
+ ScDocShellRef xDocSh = loadDoc("opencl/math/floor.", ODS);
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+ enableOpenCL();
+ pDoc->CalcAll();
+ ScDocShellRef xDocShRes = loadDoc("opencl/math/floor.", ODS);
+ ScDocument* pDocRes = xDocShRes->GetDocument();
+ CPPUNIT_ASSERT(pDocRes);
+ for (SCROW i = 0; i <= 9; ++i)
+ {
+ double fLibre = pDoc->GetValue(ScAddress(3,i,0));
+ double fExcel = pDocRes->GetValue(ScAddress(3,i,0));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+ }
+ xDocSh->DoClose();
+ xDocShRes->DoClose();
+}
ScOpenclTest::ScOpenclTest()
: ScBootstrapFixture( "/sc/qa/unit/data" )
{
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 7c10c83..3100595 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1422,6 +1422,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
case ocChiSqDist:
case ocChiSqInv:
case ocGammaInv:
+ case ocFloor:
// Don't change the state.
break;
default:
commit c41db78b286fcfba1a03a29045105915f50f48b8
Author: dechuang <dechuang at multicorewareinc.com>
Date: Sat Nov 9 10:54:40 2013 +0800
GPU Calc: implemented FLOOR
AMLOEXT-169 FIX
Refacting:add NAN processing in max/min formule under the fixed window condition
Signed-off-by: haochen <haochen at multicorewareinc.com>
Change-Id: I619e18b951070d5c8e9d63aef288992f124eceac
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 2953d67..3f7af72 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -407,12 +407,9 @@ public:
ss << "0; i < "<< nCurWindowSize << "; i++)\n\t\t";
#endif
}
- else {
-#ifdef ISNAN
- ss << "0; i < "<< nCurWindowSize << "; i++){\n\t\t";
-#else
- ss << "0; i < "<< nCurWindowSize << "; i++)\n\t\t";
-#endif
+ else
+ {
+ ss << "0; i < "<< pDVR->GetArrayLength() << "; i++){\n\t\t";
}
nItems += nCurWindowSize;
}
@@ -1240,6 +1237,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpGammaInv));
break;
+ case ocFloor:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpFloor));
+ break;
case ocExternal:
if ( !(pChild->GetExternal().compareTo(OUString(
"com.sun.star.sheet.addin.Analysis.getEffect"))))
diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx
index 671cb2f..ab556d9 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -789,6 +789,56 @@ void OpOdd::GenSlidingWindowFunction(
ss << "}";
}
+void OpFloor::GenSlidingWindowFunction(
+ std::stringstream &ss, const std::string sSymName,
+ SubArguments &vSubArguments)
+{
+ FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
+ const formula::SingleVectorRefToken*tmpCurDVR= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur);
+ ss << "\ndouble " << sSymName;
+ ss << "_"<< BinFuncName() <<"(";
+ for (unsigned i = 0; i < vSubArguments.size(); i++)
+ {
+ if (i)
+ ss << ",";
+ vSubArguments[i]->GenSlidingWindowDecl(ss);
+ }
+ ss << ")\n{\n";
+ ss <<" int gid0=get_global_id(0);\n";
+ ss << " double arg0 = " << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+ ss << " double arg1 = " << vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+ ss << " double arg2 = " << vSubArguments[2]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+#ifdef ISNAN
+ ss<< " if(isNan(arg0)||(gid0>=";
+ ss<<tmpCurDVR->GetArrayLength();
+ ss<<"))\n";
+ ss<<" arg0 = 0;\n";
+ ss<< " if(isNan(arg1)||(gid0>=";
+ ss<<tmpCurDVR->GetArrayLength();
+ ss<<"))\n";
+ ss<<" arg1 = 0;\n";
+ ss<< " if(isNan(arg2)||(gid0>=";
+ ss<<tmpCurDVR->GetArrayLength();
+ ss<<"))\n";
+ ss<<" arg2 = 0;\n";
+#endif
+ ss <<" if(arg1==0.0)\n";
+ ss <<" return 0.0;\n";
+ ss <<" else if(arg0*arg1<0.0)\n";
+ ss <<" return 0.0000000001;\n";
+ ss <<" else if(arg2==0.0&&arg0<0.0)\n";
+ ss <<" return (trunc(arg0/arg1)+1)*arg1;\n";
+ ss <<" else\n";
+ ss <<" return trunc(arg0/arg1)*arg1;\n";
+ ss << "}\n";
+}
+
+
+
}}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx
index c1feb03..22f70c9 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -197,6 +197,13 @@ public:
const std::string sSymName, SubArguments &vSubArguments);
virtual std::string BinFuncName(void) const { return "Odd"; }
};
+class OpFloor: public Normal
+{
+public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments);
+ virtual std::string BinFuncName(void) const { return "Floor"; }
+};
}}
#endif
commit 6bc2c27f983c83745a17fe5c283d53a156053879
Author: mingli <mingli at multicorewareinc.com>
Date: Fri Nov 8 13:29:47 2013 +0800
GPU Calc: unit test cases for GAMMAINV
Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
AMLOEXT-158 BUG
Change-Id: Ia759d5fda3c96aafb51cd8bd7d6a9789b5fc149d
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/qa/unit/data/xls/opencl/statistical/GammaInv.xls b/sc/qa/unit/data/xls/opencl/statistical/GammaInv.xls
new file mode 100644
index 0000000..077cfad
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/statistical/GammaInv.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index b1b0ad1..e8f5509 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -188,6 +188,7 @@ public:
void testMathFormulaOdd();
void testStatisticalFormulaChiSqDist();
void testStatisticalFormulaChiSqInv();
+ void testStatisticalFormulaGammaInv();
CPPUNIT_TEST_SUITE(ScOpenclTest);
CPPUNIT_TEST(testSharedFormulaXLS);
CPPUNIT_TEST(testFinacialFormula);
@@ -307,6 +308,7 @@ public:
CPPUNIT_TEST(testMathFormulaOdd);
CPPUNIT_TEST(testStatisticalFormulaChiSqDist);
CPPUNIT_TEST(testStatisticalFormulaChiSqInv);
+ CPPUNIT_TEST(testStatisticalFormulaGammaInv);
CPPUNIT_TEST_SUITE_END();
private:
@@ -3358,6 +3360,33 @@ void ScOpenclTest::testStatisticalFormulaGammaDist()
xDocSh->DoClose();
xDocShRes->DoClose();
}
+//[AMLOEXT-158]
+void ScOpenclTest::testStatisticalFormulaGammaInv()
+{
+ if (!detectOpenCLDevice())
+ return;
+
+ ScDocShellRef xDocSh = loadDoc("opencl/statistical/GammaInv.", XLS);
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+ enableOpenCL();
+ pDoc->CalcAll();
+ ScDocShellRef xDocShRes = loadDoc("opencl/statistical/GammaInv.", XLS);
+ ScDocument* pDocRes = xDocShRes->GetDocument();
+ CPPUNIT_ASSERT(pDocRes);
+ // Check the results of formula cells in the shared formula range.
+ for (SCROW i = 1; i <= 19; ++i)
+ {
+ double fLibre = pDoc->GetValue(ScAddress(3,i,0));
+ double fExcel = pDocRes->GetValue(ScAddress(3,i,0));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+ fLibre = pDoc->GetValue(ScAddress(4,i,0));
+ fExcel = pDocRes->GetValue(ScAddress(4,i,0));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+ }
+ xDocSh->DoClose();
+ xDocShRes->DoClose();
+}
//[AMLOEXT-166]
void ScOpenclTest::testStatisticalFormulaChiDist()
{
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index ae1a14f..7c10c83 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1421,6 +1421,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
case ocOdd:
case ocChiSqDist:
case ocChiSqInv:
+ case ocGammaInv:
// Don't change the state.
break;
default:
commit e3ae4a6dd2bae2ec379c97a3040db5312e1b62c6
Author: mingli <mingli at multicorewareinc.com>
Date: Fri Nov 8 13:39:41 2013 +0800
GPU Calc: implemented GAMMAINV
AMLOEXT-158 FIX
Change-Id: I1b6c9102342ce06d72525f63bbc04d8d832597eb
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index e75ef48..2953d67 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1236,6 +1236,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i],new OpChiSqInv));
break;
+ case ocGammaInv:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpGammaInv));
+ 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 88ccdab..c3ffb5e 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -3055,6 +3055,216 @@ vSubArguments)
}
}
+void OpGammaInv::BinInlineFun(std::set<std::string>& decls,
+ std::set<std::string>& funs)
+{
+ decls.insert(fBigInvDecl);decls.insert(fHalfMachEpsDecl);
+ decls.insert(GetGammaSeriesDecl);decls.insert(GetGammaContFractionDecl);
+ decls.insert(GetGammaInvValueDecl);
+ funs.insert(GetGammaSeries);funs.insert(GetGammaContFraction);
+ funs.insert(GetGammaInvValue);
+}
+
+void OpGammaInv::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 << " double tmp;\n";
+ ss << " double arg0,arg1,arg2;\n";
+ size_t i = vSubArguments.size();
+ size_t nItems = 0;
+ for (i = 0; i < vSubArguments.size(); i++)
+ {
+ FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
+ assert(pCur);
+ if (pCur->GetType() == formula::svDoubleVectorRef)
+ {
+ const formula::DoubleVectorRefToken* pDVR =
+ dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
+ size_t nCurWindowSize = pDVR->GetRefRowSize();
+ ss << "for (int i = ";
+ if (!pDVR->IsStartFixed() && pDVR->IsEndFixed()) {
+#ifdef ISNAN
+ ss << "gid0; i < " << pDVR->GetArrayLength();
+ ss << " && i < " << nCurWindowSize << "; i++){\n";
+#else
+ ss << "gid0; i < "<< nCurWindowSize << "; i++)\n";
+#endif
+ } else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed()) {
+#ifdef ISNAN
+ ss << "0; i < " << pDVR->GetArrayLength();
+ ss << " && i < gid0+"<< nCurWindowSize << "; i++){\n";
+#else
+ ss << "0; i < gid0+"<< nCurWindowSize << "; i++)\n ";
+#endif
+ } else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed()){
+#ifdef ISNAN
+ ss << "0; i + gid0 < " << pDVR->GetArrayLength();
+ ss << " && i < "<< nCurWindowSize << "; i++){\n ";
+#else
+ ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+#endif
+ }
+ else {
+#ifdef ISNAN
+ ss << "0; i < "<< nCurWindowSize << "; i++){\n";
+#else
+ ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+#endif
+ }
+ nItems += nCurWindowSize;
+ }
+ else if (pCur->GetType() == formula::svSingleVectorRef)
+ {
+#ifdef ISNAN
+ const formula::SingleVectorRefToken* pSVR =
+ dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
+ ss << " if (gid0 < " << pSVR->GetArrayLength() << ")\n";
+ ss << " {\n";
+ ss << " if (isNan(";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << "))\n";
+ ss << " arg"<<i<<"= 0;\n";
+ ss << " else\n";
+ ss << " arg"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+ ss << " }\n";
+ ss << " else\n";
+ ss << " arg"<<i<<"= 0;\n";
+#endif
+ }
+ else if (pCur->GetType() == formula::svDouble)
+ {
+#ifdef ISNAN
+ ss << " if (isNan(";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << "))\n";
+ ss << " arg"<<i<<"= 0;\n";
+ ss << " else\n";
+ ss << " arg"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+#endif
+ }
+ }
+ ss << " if (arg0 == 0.0)\n"
+ " {\n"
+ " tmp=0.0;\n"
+ " return tmp;\n"
+ " }\n"
+ " else\n"
+ " {\n"
+ " bool bConvError;\n"
+ " double fStart = arg1 * arg2;\n"
+ " double fAx=fStart*0.5;\n"
+ " double fBx=fStart;\n"
+ " bConvError = false;\n"
+ " double fYEps = 1.0E-307;\n"
+ " double fXEps = 2.22045e-016;\n"
+ " double fAy = arg0-GetGammaInvValue(arg1,arg2,fAx);\n"
+ " double fBy = arg0-GetGammaInvValue(arg1,arg2,fBx);\n"
+ " double fTemp;\n"
+ " unsigned short nCount;\n"
+ " for (nCount = 0; nCount < 1000 && !((fAy < 0.0 && fBy > 0.0)"
+ " || (fAy > 0.0 && fBy < 0.0)); nCount++)\n"
+ " {\n"
+ " if (fabs(fAy) <= fabs(fBy))\n"
+ " {\n"
+ " fTemp = fAx;\n"
+ " fAx += 2.0 * (fAx - fBx);\n"
+ " if (fAx < 0.0)\n"
+ " fAx = 0.0;\n"
+ " fBx = fTemp;\n"
+ " fBy = fAy;\n"
+ " fAy = arg0-GetGammaInvValue(arg1,arg2,fAx);\n"
+ " }\n"
+ " else\n"
+ " {\n"
+ " fTemp = fBx;\n"
+ " fBx += 2.0 * (fBx - fAx);\n"
+ " fAx = fTemp;\n"
+ " fAy = fBy;\n"
+ " fBy = arg0-GetGammaInvValue(arg1,arg2,fBx);\n"
+ " }\n"
+ " }\n"
+ " if (fAy == 0.0)\n"
+ " {\n"
+ " tmp = fAx;\n"
+ " return tmp;\n"
+ " }\n"
+ " if (fBy == 0.0)\n"
+ " {\n"
+ " tmp = fBx;\n"
+ " return tmp;\n"
+ " }\n"
+ " if (!((fAy < 0.0 && fBy > 0.0) || (fAy > 0.0 && fBy < 0.0)))\n"
+ " {\n"
+ " bConvError = true;\n"
+ " tmp = 0.0;\n"
+ " return tmp;\n"
+ " }\n"
+ " double fPx = fAx;\n"
+ " double fPy = fAy;\n"
+ " double fQx = fBx;\n"
+ " double fQy = fBy;\n"
+ " double fRx = fAx;\n"
+ " double fRy = fAy;\n"
+ " double fSx = 0.5 * (fAx + fBx);\n"
+ " bool bHasToInterpolate = true;\n"
+ " nCount = 0;\n"
+ " while ( nCount < 500 && fabs(fRy) > fYEps &&"
+ "(fBx-fAx) > fmax( fabs(fAx), fabs(fBx)) * fXEps )\n"
+ " {\n"
+ " if (bHasToInterpolate)\n"
+ " {\n"
+ " if (fPy!=fQy && fQy!=fRy && fRy!=fPy)\n"
+ " {\n"
+ " fSx = fPx * fRy * fQy / (fRy-fPy) / (fQy-fPy)"
+ "+ fRx * fQy * fPy / (fQy-fRy) / (fPy-fRy)"
+ "+ fQx * fPy * fRy / (fPy-fQy) / (fRy-fQy);\n"
+ " bHasToInterpolate = (fAx < fSx) && (fSx < fBx);\n"
+ " }\n"
+ " else\n"
+ " bHasToInterpolate = false;\n"
+ " }\n"
+ " if(!bHasToInterpolate)\n"
+ " {\n"
+ " fSx = 0.5 * (fAx + fBx);\n"
+ " fPx = fAx; fPy = fAy;\n"
+ " fQx = fBx; fQy = fBy;\n"
+ " bHasToInterpolate = true;\n"
+ " }\n"
+ " fPx = fQx; fQx = fRx; fRx = fSx;\n"
+ " fPy = fQy; fQy = fRy;\n"
+ " fRy = arg0-GetGammaInvValue(arg1,arg2,fSx);\n"
+ " if ((fAy < 0.0 && fRy > 0.0) || (fAy > 0.0 && fRy < 0.0))\n"
+ " {\n"
+ " fBx = fRx;\n"
+ " fBy = fRy;\n"
+ " }\n"
+ " else\n"
+ " {\n"
+ " fAx = fRx;\n"
+ " fAy = fRy;\n"
+ " }\n"
+ " bHasToInterpolate = bHasToInterpolate && (fabs(fRy)"
+ " * 2.0 <= fabs(fQy));\n"
+ " ++nCount;\n"
+ " }\n"
+ " tmp = fRx;\n"
+ " return tmp;\n"
+ " }\n"
+ "}\n";
+}
+
}}
diff --git a/sc/source/core/opencl/op_statistical.hxx b/sc/source/core/opencl/op_statistical.hxx
index e609dc0..153d1e9 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -270,6 +270,15 @@ public:
virtual std::string BinFuncName(void) const { return "ChiSqInv"; }
virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>& );
};
+class OpGammaInv: public Normal
+{
+public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments);
+ void BinInlineFun(std::set<std::string>& decls,std::set<std::string>& funs
+);
+ virtual std::string BinFuncName(void) const { return "GammaInv"; }
+};
}}
commit c4d4c702e11fe440c795dab5f108605eb21377a6
Author: yiming ju <yiming at multicorewareinc.com>
Date: Fri Nov 8 13:01:01 2013 +0800
GPU Calc: unit test cases for CHISQINV
Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
AMLOEXT-148 BUG
Change-Id: If9a1c7a35220d405cdbb0d60aa2e5209c542eefb
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/qa/unit/data/ods/opencl/statistical/CHISQINV.ods b/sc/qa/unit/data/ods/opencl/statistical/CHISQINV.ods
new file mode 100644
index 0000000..2071bc5
Binary files /dev/null and b/sc/qa/unit/data/ods/opencl/statistical/CHISQINV.ods differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 76cf866..b1b0ad1 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -187,6 +187,7 @@ public:
void testMathFormulaPower();
void testMathFormulaOdd();
void testStatisticalFormulaChiSqDist();
+ void testStatisticalFormulaChiSqInv();
CPPUNIT_TEST_SUITE(ScOpenclTest);
CPPUNIT_TEST(testSharedFormulaXLS);
CPPUNIT_TEST(testFinacialFormula);
@@ -305,6 +306,7 @@ public:
CPPUNIT_TEST(testMathFormulaPower);
CPPUNIT_TEST(testMathFormulaOdd);
CPPUNIT_TEST(testStatisticalFormulaChiSqDist);
+ CPPUNIT_TEST(testStatisticalFormulaChiSqInv);
CPPUNIT_TEST_SUITE_END();
private:
@@ -3210,6 +3212,29 @@ void ScOpenclTest:: testFinacialNPER1Formula()
xDocSh->DoClose();
xDocShRes->DoClose();
}
+//[AMLOEXT-148]
+void ScOpenclTest::testStatisticalFormulaChiSqInv()
+{
+ if (!detectOpenCLDevice())
+ return;
+ ScDocShellRef xDocSh = loadDoc("opencl/statistical/CHISQINV.", ODS);
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+ enableOpenCL();
+ pDoc->CalcAll();
+ ScDocShellRef xDocShRes = loadDoc("opencl/statistical/CHISQINV.", ODS);
+ ScDocument* pDocRes = xDocShRes->GetDocument();
+ CPPUNIT_ASSERT(pDocRes);
+ // Check the results of formula cells in the shared formula range.
+ for (SCROW i = 1; i <= 9; ++i)
+ {
+ double fLibre = pDoc->GetValue(ScAddress(2,i,0));
+ double fExcel = pDocRes->GetValue(ScAddress(2,i,0));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+ }
+ xDocSh->DoClose();
+ xDocShRes->DoClose();
+}
//[AMLOEXT-149]
void ScOpenclTest::testMathFormulaBitAnd()
{
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 11c5737..ae1a14f 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1420,6 +1420,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
case ocPower:
case ocOdd:
case ocChiSqDist:
+ case ocChiSqInv:
// Don't change the state.
break;
default:
commit 374f670aea4c2581c1e813c39571819fecdff4f4
Author: yiming ju <yiming at multicorewareinc.com>
Date: Fri Nov 8 13:19:10 2013 +0800
GPU Calc: implemented CHISQINV
AMLOEXT-148 FIX
Change-Id: I2f41abf89b8714e854efde85b88c2c2998d6da1a
Refacotring: convert fmax&fmin to max&min
Signed-off-by: haochen <haochen at multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index a4e99e0..e75ef48 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -696,9 +696,9 @@ public:
virtual std::string GetBottom(void) { return "MAXFLOAT"; }
virtual std::string Gen2(const std::string &lhs, const std::string &rhs) const
{
- return "fmin("+lhs + "," + rhs +")";
+ return "min("+lhs + "," + rhs +")";
}
- virtual std::string BinFuncName(void) const { return "fmin"; }
+ virtual std::string BinFuncName(void) const { return "min"; }
};
class OpMax: public Reduction {
@@ -706,9 +706,9 @@ public:
virtual std::string GetBottom(void) { return "-MAXFLOAT"; }
virtual std::string Gen2(const std::string &lhs, const std::string &rhs) const
{
- return "fmax("+lhs + "," + rhs +")";
+ return "max("+lhs + "," + rhs +")";
}
- virtual std::string BinFuncName(void) const { return "fmax"; }
+ virtual std::string BinFuncName(void) const { return "max"; }
};
class OpSumProduct: public SumOfProduct {
public:
@@ -1232,6 +1232,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i],new OpChiSqDist));
break;
+ case ocChiSqInv:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i],new OpChiSqInv));
+ 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 a9cfbd2..88ccdab 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -3000,6 +3000,61 @@ vSubArguments)
}
+ void OpChiSqInv::BinInlineFun(std::set<std::string>& decls,
+ std::set<std::string>& funs)
+{
+ decls.insert(fMaxGammaArgumentDecl);decls.insert(GetChiSqDistCDFDecl);
+ decls.insert(GetLowRegIGammaDecl);decls.insert(lcl_IterateInverseChiSQInvDecl);
+ decls.insert(GetGammaContFractionDecl);decls.insert(GetGammaSeriesDecl);
+ decls.insert(fHalfMachEpsDecl);decls.insert(F_PIDecl);
+ decls.insert(fBigInvDecl);decls.insert(lcl_HasChangeOfSignDecl);
+ decls.insert(fMachEpsDecl);
+
+ funs.insert(GetGammaContFraction);funs.insert(GetChiSqDistCDF);
+ funs.insert(GetLowRegIGamma);funs.insert(lcl_HasChangeOfSign);
+ funs.insert(GetGammaSeries);funs.insert(lcl_IterateInverseChiSQInv);
+}
+
+void OpChiSqInv::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);
+ ss << " tmp1 = floor(tmp1);\n";
+ ss << " bool bConvError;\n";
+ ss << " if(tmp1 < 1.0 || tmp0 < 0 || tmp0>=1.0)\n";
+ ss << " result = -DBL_MAX;\n";
+ ss << " else\n";
+ ss << " {\n";
+ ss << " result =lcl_IterateInverseChiSQInv( tmp0, tmp1,";
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list