[Libreoffice-commits] core.git: 10 commits - sc/qa sc/source

2013-12-23 Thread hongyu zhong
 sc/qa/unit/data/xls/opencl/math/iseven.xls |binary
 sc/qa/unit/data/xls/opencl/math/isodd.xls  |binary
 sc/source/core/opencl/op_financial.cxx |  313 +
 sc/source/core/opencl/op_math.cxx  |   24 +
 sc/source/core/opencl/op_math.hxx  |3 
 sc/source/core/opencl/op_statistical.cxx   |  190 ++-
 sc/source/core/opencl/opinlinefun_finacial.cxx |   49 +++
 sc/source/core/opencl/opinlinefun_math.hxx |   29 ++
 8 files changed, 347 insertions(+), 261 deletions(-)

New commits:
commit 2bb1a845a25ca9a39c96f37995453844461aed4e
Author: hongyu zhong 
Date:   Fri Dec 20 14:41:47 2013 +0800

GPU Calc: Optimized CHISQINV

AMLOEXT-300

Change-Id: I01f16fb5a00e1c96e40bfcf99e417519cb27e765
Signed-off-by: haochen 
Signed-off-by: Wei Wei 
Signed-off-by: I-Jui (Ray) Sung 

diff --git a/sc/source/core/opencl/op_statistical.cxx 
b/sc/source/core/opencl/op_statistical.cxx
index 8275aaa..a98a08e 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -7125,6 +7125,46 @@ vSubArguments)
 {
 GenTmpVariables(ss,vSubArguments);
 CheckAllSubArgumentIsNan(ss,vSubArguments);
+size_t i = vSubArguments.size();
+ss <<"\n";
+for (i = 0; i < vSubArguments.size(); i++)
+{
+FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
+assert(pCur);
+if (pCur->GetType() == formula::svSingleVectorRef)
+{
+#ifdef  ISNAN
+const formula::SingleVectorRefToken* pSVR =
+dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
+ss << "if (gid0 < " << pSVR->GetArrayLength() << "){\n";
+#endif
+}
+else if (pCur->GetType() == formula::svDouble)
+{
+#ifdef  ISNAN
+ss << "{\n";
+#endif
+}
+
+#ifdef  ISNAN
+if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
+{
+ss << "if (isNan(";
+ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ss << "))\n";
+ss << "tmp"<GenSlidingWindowDeclRef();
+ss << ";\n}\n";
+}
+else
+{
+ss << "tmp"<GenSlidingWindowDeclRef();
+ss <<";\n";
+}
+#endif
+}
 ss << "tmp1 = floor(tmp1);\n";
 ss << "bool bConvError;\n";
 ss << "if(tmp1 < 1.0 || tmp0 < 0 || tmp0>=1.0)\n";
commit 99b93d898f2aff3198146c1e8aa44b9dfae177b9
Author: yangzhang 
Date:   Fri Dec 20 14:07:56 2013 +0800

GPU Calc: Optimized ACOS

AMLOEXT-270

Change-Id: I460354ede9a9666a7b5dcd7c5d125b605e3b3b2d
Signed-off-by: haochen 
Signed-off-by: Wei Wei 
Signed-off-by: I-Jui (Ray) Sung 

diff --git a/sc/source/core/opencl/op_math.cxx 
b/sc/source/core/opencl/op_math.cxx
index f0ed0b1..3f742f8 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1032,6 +1032,12 @@ void OpAbs::GenSlidingWindowFunction(std::stringstream 
&ss,
 ss << "return fabs(tmp);\n";
 ss << "}";
 }
+void OpArcCos::BinInlineFun(std::set& decls,
+std::set& funs)
+{
+decls.insert(atan2Decl);
+funs.insert(atan2Content);
+}
 void OpArcCos::GenSlidingWindowFunction(std::stringstream &ss,
 const std::string sSymName, SubArguments &vSubArguments)
 {
@@ -1057,7 +1063,7 @@ void OpArcCos::GenSlidingWindowFunction(std::stringstream 
&ss,
 #endif
 ss << "tmp = ";
 ss << vSubArguments[0]->GenSlidingWindowDeclRef()<< ";\n";
-ss << "return acos(tmp);\n";
+ss << "return arctan2(sqrt(1.0 - pow(tmp, 2)), tmp);\n";
 ss << "}";
 }
 void OpArcCosHyp::GenSlidingWindowFunction(std::stringstream &ss,
diff --git a/sc/source/core/opencl/op_math.hxx 
b/sc/source/core/opencl/op_math.hxx
index e10dfa1..5864161 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -101,6 +101,7 @@ public:
 const std::string sSymName, SubArguments &vSubArguments);
 virtual std::string GetBottom(void) { return "0.0"; }
 virtual std::string BinFuncName(void) const { return "ScACos"; }
+virtual void BinInlineFun(std::set& ,std::set&);
 };
 class OpArcCosHyp:public Normal{
 public:
commit 3eb75fa4d7f0c7c87cc0b20a0a246c956ae8816a
Author: yangzhang 
Date:   Fri Dec 20 14:04:34 2013 +0800

GPU Calc: Optimized ASIN

AMLOEXT-269

Change-Id: I10d33b50f743630ed91daa743017e431754e5659
Signed-off-by: haochen 

[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - 2 commits - sc/qa sc/source

2013-11-16 Thread hongyu zhong
 sc/qa/unit/data/xls/opencl/statistical/Betainv.xls |binary
 sc/qa/unit/opencl-test.cxx |   25 +++
 sc/source/core/opencl/formulagroupcl.cxx   |5 
 sc/source/core/opencl/op_statistical.cxx   |  153 +
 sc/source/core/opencl/op_statistical.hxx   |8 -
 sc/source/core/opencl/opbase.cxx   |4 
 sc/source/core/opencl/opinlinefun_statistical.cxx  |1 
 sc/source/core/tool/token.cxx  |1 
 8 files changed, 193 insertions(+), 4 deletions(-)

New commits:
commit ca30bd2c6c637746fb56dc9ef45bc84baa743faa
Author: hongyu zhong 
Date:   Sat Nov 16 17:33:30 2013 +0800

GPU Calc: implemented BETAINV

AMLOEXT-201 FIX

Change-Id: I68a7277b7353ed5a6f4d2ea8d1a4f7fb894bf487
Signed-off-by: haochen 

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index b9469f2..0d63e4c 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1762,6 +1762,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
 mvSubArguments.push_back(SoPHelper(ts,
  ft->Children[i],new OpSumX2PY2));
  break;
+case ocBetaInv:
+mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i],new OpBetainv));
+ 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 ddad803..48c015d 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -6198,6 +6198,159 @@ void 
OpBetaDist::GenSlidingWindowFunction(std::stringstream &ss,
 ss << "return tmp;\n";
 ss << "}\n";
 }
+void OpBetainv::BinInlineFun(std::set& decls,
+std::set& funs)
+{
+decls.insert(fMachEpsDecl);
+funs.insert("");
+decls.insert(fMaxGammaArgumentDecl);
+funs.insert("");
+decls.insert(lcl_IterateInverseBetaInvDecl);
+funs.insert(lcl_IterateInverseBetaInv);
+decls.insert(GetBetaDistDecl);
+funs.insert(GetBetaDist);
+decls.insert(lcl_HasChangeOfSignDecl);
+funs.insert(lcl_HasChangeOfSign);
+decls.insert(lcl_HasChangeOfSignDecl);
+funs.insert(lcl_HasChangeOfSign);
+decls.insert(lcl_HasChangeOfSignDecl);
+funs.insert(lcl_HasChangeOfSign);
+decls.insert(lcl_GetBetaHelperContFracDecl);
+funs.insert(lcl_GetBetaHelperContFrac);
+decls.insert(GetBetaDistPDFDecl);
+funs.insert(GetBetaDistPDF);
+decls.insert(GetLogBetaDecl);
+funs.insert(GetLogBeta);
+decls.insert(GetBetaDecl);
+funs.insert(GetBeta);
+decls.insert(lcl_getLanczosSumDecl);
+funs.insert(lcl_getLanczosSum);
+}
+void OpBetainv::GenSlidingWindowFunction(
+std::stringstream &ss,const std::string sSymName,
+SubArguments &vSubArguments)
+{
+ss << "\ndouble " << sSymName;
+ss << "_"<< BinFuncName() <<"(";
+for (unsigned i = 0; i < vSubArguments.size(); i++)
+{
+if (i)
+ss << ",";
+vSubArguments[i]->GenSlidingWindowDecl(ss);
+}
+ss << ")\n";
+ss << "{\n";
+ss << "double tmp0,tmp1,tmp2,tmp3,tmp4;\n";
+ss << "int gid0=get_global_id(0);\n";
+size_t i = vSubArguments.size();
+size_t nItems = 0;
+ss <<"\n";
+//while (i-- > 1)
+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(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";
+

[Libreoffice-commits] core.git: 3 commits - sc/qa sc/source

2013-11-16 Thread hongyu zhong
 sc/qa/unit/data/xls/opencl/statistical/Betainv.xls |binary
 sc/qa/unit/opencl-test.cxx |   25 +++
 sc/source/core/opencl/formulagroupcl.cxx   |   10 +
 sc/source/core/opencl/op_statistical.cxx   |  153 +
 sc/source/core/opencl/op_statistical.hxx   |8 -
 sc/source/core/opencl/opbase.cxx   |4 
 sc/source/core/opencl/opinlinefun_statistical.cxx  |1 
 sc/source/core/tool/token.cxx  |1 
 8 files changed, 197 insertions(+), 5 deletions(-)

New commits:
commit 811c671c7ff3229dab1ed9ae81fa9723c603fa80
Author: hongyu zhong 
Date:   Sat Nov 16 17:33:30 2013 +0800

GPU Calc: implemented BETAINV

AMLOEXT-201 FIX

Change-Id: I68a7277b7353ed5a6f4d2ea8d1a4f7fb894bf487
Signed-off-by: haochen 

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index 45ab642..d2a10c5 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1762,6 +1762,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
 mvSubArguments.push_back(SoPHelper(ts,
  ft->Children[i],new OpSumX2PY2));
  break;
+case ocBetaInv:
+mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i],new OpBetainv));
+ 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 ddad803..48c015d 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -6198,6 +6198,159 @@ void 
OpBetaDist::GenSlidingWindowFunction(std::stringstream &ss,
 ss << "return tmp;\n";
 ss << "}\n";
 }
+void OpBetainv::BinInlineFun(std::set& decls,
+std::set& funs)
+{
+decls.insert(fMachEpsDecl);
+funs.insert("");
+decls.insert(fMaxGammaArgumentDecl);
+funs.insert("");
+decls.insert(lcl_IterateInverseBetaInvDecl);
+funs.insert(lcl_IterateInverseBetaInv);
+decls.insert(GetBetaDistDecl);
+funs.insert(GetBetaDist);
+decls.insert(lcl_HasChangeOfSignDecl);
+funs.insert(lcl_HasChangeOfSign);
+decls.insert(lcl_HasChangeOfSignDecl);
+funs.insert(lcl_HasChangeOfSign);
+decls.insert(lcl_HasChangeOfSignDecl);
+funs.insert(lcl_HasChangeOfSign);
+decls.insert(lcl_GetBetaHelperContFracDecl);
+funs.insert(lcl_GetBetaHelperContFrac);
+decls.insert(GetBetaDistPDFDecl);
+funs.insert(GetBetaDistPDF);
+decls.insert(GetLogBetaDecl);
+funs.insert(GetLogBeta);
+decls.insert(GetBetaDecl);
+funs.insert(GetBeta);
+decls.insert(lcl_getLanczosSumDecl);
+funs.insert(lcl_getLanczosSum);
+}
+void OpBetainv::GenSlidingWindowFunction(
+std::stringstream &ss,const std::string sSymName,
+SubArguments &vSubArguments)
+{
+ss << "\ndouble " << sSymName;
+ss << "_"<< BinFuncName() <<"(";
+for (unsigned i = 0; i < vSubArguments.size(); i++)
+{
+if (i)
+ss << ",";
+vSubArguments[i]->GenSlidingWindowDecl(ss);
+}
+ss << ")\n";
+ss << "{\n";
+ss << "double tmp0,tmp1,tmp2,tmp3,tmp4;\n";
+ss << "int gid0=get_global_id(0);\n";
+size_t i = vSubArguments.size();
+size_t nItems = 0;
+ss <<"\n";
+//while (i-- > 1)
+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(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";
+

[Libreoffice-commits] core.git: 4 commits - sc/qa sc/source

2013-11-11 Thread hongyu zhong
 sc/qa/unit/data/xls/opencl/statistical/Median.xls  |binary
 sc/qa/unit/data/xls/opencl/statistical/Weibull.xls |binary
 sc/qa/unit/opencl-test.cxx |   52 +
 sc/source/core/opencl/formulagroupcl.cxx   |8 
 sc/source/core/opencl/op_statistical.cxx   |  217 +
 sc/source/core/opencl/op_statistical.hxx   |   14 +
 sc/source/core/tool/token.cxx  |2 
 7 files changed, 293 insertions(+)

New commits:
commit 62ee42a209dfd4862cab9311868f4f38a6e000ac
Author: hongyu zhong 
Date:   Mon Nov 4 17:31:04 2013 +0800

GPU Calc: unit test cases for MEDIAN

Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test

AMLOEXT-100 BUG

Change-Id: Idbc6a697c42b639a310200b4df9eb35ba5e8eca7
Signed-off-by: haochen 
Signed-off-by: I-Jui (Ray) Sung 

diff --git a/sc/qa/unit/data/xls/opencl/statistical/Median.xls 
b/sc/qa/unit/data/xls/opencl/statistical/Median.xls
new file mode 100644
index 000..232629e
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/statistical/Median.xls 
differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index b406894..b593174 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -130,6 +130,7 @@ public:
 void testMathFormulaTanH();
 void testStatisticalFormulaStandard();
 void testStatisticalFormulaWeibull();
+void testStatisticalFormulaMedian();
 CPPUNIT_TEST_SUITE(ScOpenclTest);
 CPPUNIT_TEST(testSharedFormulaXLS);
 CPPUNIT_TEST(testFinacialFormula);
@@ -191,6 +192,7 @@ public:
 CPPUNIT_TEST(testMathFormulaTanH);
 CPPUNIT_TEST(testStatisticalFormulaStandard);
 CPPUNIT_TEST(testStatisticalFormulaWeibull);
+CPPUNIT_TEST(testStatisticalFormulaMedian);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1532,6 +1534,29 @@ void ScOpenclTest:: testFinancialISPMTFormula()
 xDocSh->DoClose();
 xDocShRes->DoClose();
 }
+//[AMLOEXT-100]
+void ScOpenclTest::testStatisticalFormulaMedian()
+{
+if (!detectOpenCLDevice())
+return;
+ScDocShellRef xDocSh = loadDoc("opencl/statistical/Median.",XLS);
+ScDocument* pDoc = xDocSh->GetDocument();
+CPPUNIT_ASSERT(pDoc);
+enableOpenCL();
+pDoc->CalcAll();
+ScDocShellRef xDocShRes = loadDoc("opencl/statistical/Median.",XLS);
+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(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();
+}
 void ScOpenclTest::testFinacialPriceMatFormula()
 {
 if (!detectOpenCLDevice())
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index e72e026..1bcf726 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1376,6 +1376,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
 case ocTanHyp:
 case ocStandard:
 case ocWeibull:
+case ocMedian:
 // Don't change the state.
 break;
 default:
commit eb2c6bd19faca2607fa425bbd7f8a95f5407a1ac
Author: hongyu zhong 
Date:   Mon Nov 4 17:39:20 2013 +0800

GPU Calc: implemented MEDIAN

AMLOEXT-100 FIX

Change-Id: I9b002e6c2383c4416b98e6698d3dd2e81f7752f5
Signed-off-by: haochen 
Signed-off-by: I-Jui (Ray) Sung 

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index 380a6a6..60b126c 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1052,6 +1052,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
 mvSubArguments.push_back(SoPHelper(ts,
  ft->Children[i], new OpWeibull));
 break;
+case ocMedian:
+mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i],new OpMedian));
+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 64f2411..356b170 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -939,6 +939,83 @@ void OpRsq::GenSlidingWindowFunction(
 ss << "}\n";
 }
 
+void OpMedian::GenSlidingWindowFunction(
+std::stringstream &ss, const std::string sSymName,
+SubArguments &vSubArguments)
+{
+ss << "\n

[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - 4 commits - sc/qa sc/source

2013-11-11 Thread hongyu zhong
 sc/qa/unit/data/xls/opencl/statistical/Median.xls  |binary
 sc/qa/unit/data/xls/opencl/statistical/Weibull.xls |binary
 sc/qa/unit/opencl-test.cxx |   52 +
 sc/source/core/opencl/formulagroupcl.cxx   |8 
 sc/source/core/opencl/op_statistical.cxx   |  217 +
 sc/source/core/opencl/op_statistical.hxx   |   14 +
 sc/source/core/tool/token.cxx  |2 
 7 files changed, 293 insertions(+)

New commits:
commit 6cb7a09682a51923e64ad5c638ff3a4ab4e7748e
Author: hongyu zhong 
Date:   Mon Nov 4 17:31:04 2013 +0800

GPU Calc: unit test cases for MEDIAN

Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test

AMLOEXT-100 BUG

Change-Id: Idbc6a697c42b639a310200b4df9eb35ba5e8eca7
Signed-off-by: haochen 
Signed-off-by: I-Jui (Ray) Sung 

diff --git a/sc/qa/unit/data/xls/opencl/statistical/Median.xls 
b/sc/qa/unit/data/xls/opencl/statistical/Median.xls
new file mode 100644
index 000..232629e
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/statistical/Median.xls 
differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 0b8166a..69c8c3e 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -132,6 +132,7 @@ public:
 void testMathFormulaTanH();
 void testStatisticalFormulaStandard();
 void testStatisticalFormulaWeibull();
+void testStatisticalFormulaMedian();
 CPPUNIT_TEST_SUITE(ScOpenclTest);
 CPPUNIT_TEST(testSharedFormulaXLS);
 CPPUNIT_TEST(testFinacialFormula);
@@ -193,6 +194,7 @@ public:
 CPPUNIT_TEST(testMathFormulaTanH);
 CPPUNIT_TEST(testStatisticalFormulaStandard);
 CPPUNIT_TEST(testStatisticalFormulaWeibull);
+CPPUNIT_TEST(testStatisticalFormulaMedian);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1534,6 +1536,29 @@ void ScOpenclTest:: testFinancialISPMTFormula()
 xDocSh->DoClose();
 xDocShRes->DoClose();
 }
+//[AMLOEXT-100]
+void ScOpenclTest::testStatisticalFormulaMedian()
+{
+if (!detectOpenCLDevice())
+return;
+ScDocShellRef xDocSh = loadDoc("opencl/statistical/Median.",XLS);
+ScDocument* pDoc = xDocSh->GetDocument();
+CPPUNIT_ASSERT(pDoc);
+enableOpenCL();
+pDoc->CalcAll();
+ScDocShellRef xDocShRes = loadDoc("opencl/statistical/Median.",XLS);
+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(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();
+}
 void ScOpenclTest::testFinacialPriceMatFormula()
 {
 if (!detectOpenCLDevice())
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index e72e026..1bcf726 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1376,6 +1376,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
 case ocTanHyp:
 case ocStandard:
 case ocWeibull:
+case ocMedian:
 // Don't change the state.
 break;
 default:
commit fb66e504b99cf09355e730b1064545ef9dc22319
Author: hongyu zhong 
Date:   Mon Nov 4 17:39:20 2013 +0800

GPU Calc: implemented MEDIAN

AMLOEXT-100 FIX

Change-Id: I9b002e6c2383c4416b98e6698d3dd2e81f7752f5
Signed-off-by: haochen 
Signed-off-by: I-Jui (Ray) Sung 

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index a6cf6e1..96e8f0f 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1052,6 +1052,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
 mvSubArguments.push_back(SoPHelper(ts,
  ft->Children[i], new OpWeibull));
 break;
+case ocMedian:
+mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i],new OpMedian));
+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 64f2411..356b170 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -939,6 +939,83 @@ void OpRsq::GenSlidingWindowFunction(
 ss << "}\n";
 }
 
+void OpMedian::GenSlidingWindowFunction(
+std::stringstream &ss, const std::string sSymName,
+SubArguments &vSubArguments)
+{
+ss << "\n