[Libreoffice-commits] core.git: 32 commits - sc/Library_scopencl.mk sc/qa sc/source

yiming ju yiming at multicorewareinc.com
Fri Nov 15 10:59:31 PST 2013


 sc/Library_scopencl.mk                                 |    1 
 sc/qa/unit/data/ods/opencl/math/Ceil.ods               |binary
 sc/qa/unit/data/ods/opencl/math/Kombin.ods             |binary
 sc/qa/unit/data/xls/opencl/array/SUMX2MY2.xls          |binary
 sc/qa/unit/data/xls/opencl/array/SUMX2PY2.xls          |binary
 sc/qa/unit/data/xls/opencl/math/convert.xls            |binary
 sc/qa/unit/data/xls/opencl/math/pi.xls                 |binary
 sc/qa/unit/data/xls/opencl/math/product.xls            |binary
 sc/qa/unit/data/xls/opencl/math/random.xls             |binary
 sc/qa/unit/data/xls/opencl/statistical/BinomDist.xls   |binary
 sc/qa/unit/data/xls/opencl/statistical/DevSq.xls       |binary
 sc/qa/unit/data/xls/opencl/statistical/HypGeomDist.xls |binary
 sc/qa/unit/data/xls/opencl/statistical/STEYX.xls       |binary
 sc/qa/unit/data/xls/opencl/statistical/Slope.xls       |binary
 sc/qa/unit/data/xls/opencl/statistical/StDev.xls       |binary
 sc/qa/unit/data/xls/opencl/statistical/VarP.xls        |binary
 sc/qa/unit/data/xls/opencl/statistical/ZTest.xls       |binary
 sc/qa/unit/opencl-test.cxx                             |  423 ++
 sc/source/core/opencl/formulagroupcl.cxx               |  150 
 sc/source/core/opencl/op_array.cxx                     |  141 
 sc/source/core/opencl/op_array.hxx                     |   37 
 sc/source/core/opencl/op_math.cxx                      |  271 +
 sc/source/core/opencl/op_math.hxx                      |   29 
 sc/source/core/opencl/op_statistical.cxx               | 2581 +++++++++++++----
 sc/source/core/opencl/op_statistical.hxx               |   55 
 sc/source/core/tool/token.cxx                          |   15 
 26 files changed, 3221 insertions(+), 482 deletions(-)

New commits:
commit a1e6bbbdaabcf37d8d8dfd89f6372e9521f36a22
Author: yiming ju <yiming at multicorewareinc.com>
Date:   Wed Nov 13 09:00:18 2013 +0800

    GPU Calc: unit test cases for SUMX2PY2
    
    Need macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-200 BUG
    
    Change-Id: I2eb1c8b30989391d683400eef89b4543edd69f1e
    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/array/SUMX2PY2.xls b/sc/qa/unit/data/xls/opencl/array/SUMX2PY2.xls
new file mode 100644
index 0000000..4b7ad1a
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/array/SUMX2PY2.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index bffd36d..81fa8eb 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -231,6 +231,7 @@ public:
     void testMathFormulaProduct();
     void testStatisticalFormulaHypGeomDist();
     void testArrayFormulaSumX2MY2();
+    void testArrayFormulaSumX2PY2();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -393,6 +394,7 @@ public:
     CPPUNIT_TEST(testMathFormulaProduct);
     CPPUNIT_TEST(testStatisticalFormulaHypGeomDist);
     CPPUNIT_TEST(testArrayFormulaSumX2MY2);
+    CPPUNIT_TEST(testArrayFormulaSumX2PY2);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -4492,7 +4494,34 @@ void ScOpenclTest::testStatisticalFormulaHypGeomDist()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
-
+//[AMLOEXT-200]
+void ScOpenclTest:: testArrayFormulaSumX2PY2()
+{
+    if (!detectOpenCLDevice())
+        return;
+    ScDocShellRef xDocSh = loadDoc("opencl/array/SUMX2PY2.", XLS);
+    ScDocument *pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/array/SUMX2PY2.", XLS);
+    ScDocument *pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    for (SCROW i = 0; 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));
+    }
+    for (SCROW i = 20; i <= 26; ++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();
+}
 ScOpenclTest::ScOpenclTest()
       : ScBootstrapFixture( "/sc/qa/unit/data" )
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 38f1b13..4c84ca4 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1462,6 +1462,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocProduct:
             case ocHypGeomDist:
             case ocSumX2MY2:
+            case ocSumX2DY2:
             // Don't change the state.
             break;
             default:
commit 2e348a2e37c702273416816122c49da90ad3bb65
Author: yiming ju <yiming at multicorewareinc.com>
Date:   Wed Nov 13 09:13:55 2013 +0800

    GPU Calc: implemented SUMX2PY2
    
    AMLOEXT-200 FIX
    
    Change-Id: I61ec2c11db0bd9bce4a0b32cf266ab39d5439a08
    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 1f3871b..6c27cd1 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1481,6 +1481,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 mvSubArguments.push_back(SoPHelper(ts,
                          ft->Children[i],new OpSumX2MY2));
                 break;
+            case ocSumX2DY2:
+                mvSubArguments.push_back(SoPHelper(ts,
+                         ft->Children[i],new OpSumX2PY2));
+                 break;
             case ocExternal:
                 if ( !(pChild->GetExternal().compareTo(OUString(
                     "com.sun.star.sheet.addin.Analysis.getEffect"))))
diff --git a/sc/source/core/opencl/op_array.cxx b/sc/source/core/opencl/op_array.cxx
index ff1f54f..e656f7b 100644
--- a/sc/source/core/opencl/op_array.cxx
+++ b/sc/source/core/opencl/op_array.cxx
@@ -79,6 +79,62 @@ void OpSumX2MY2::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "}";
 }
 
+void OpSumX2PY2::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    {\n";
+    ss << "    int gid0=get_global_id(0);\n";
+    ss << "    double tmp =0;\n";
+    GenTmpVariables(ss,vSubArguments);
+    if(vSubArguments[0]->GetFormulaToken()->GetType() ==
+    formula::svDoubleVectorRef)
+    {
+        FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
+        const formula::DoubleVectorRefToken*pCurDVR= dynamic_cast<const
+            formula::DoubleVectorRefToken *>(tmpCur);
+        size_t nCurWindowSize = pCurDVR->GetArrayLength() <
+        pCurDVR->GetRefRowSize() ? pCurDVR->GetArrayLength():
+        pCurDVR->GetRefRowSize() ;
+         ss << "    int i ;\n";
+         ss << "    for (i = ";
+         if (!pCurDVR->IsStartFixed() && pCurDVR->IsEndFixed()) {
+            ss << "gid0; i < "<< nCurWindowSize <<"; i++)\n";
+         } else if (pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed()) {
+            ss << "0; i < gid0+"<< nCurWindowSize <<"; i++)\n";
+         } else {
+            ss << "0; i < "<< nCurWindowSize <<"; i++)\n";
+         }
+         ss << "    {\n";
+         if(!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
+         {
+            ss << "    int doubleIndex =i+gid0;\n";
+         }else
+         {
+            ss << "    int doubleIndex =i;\n";
+         }
+
+        CheckSubArgumentIsNan(ss,vSubArguments,0);
+        CheckSubArgumentIsNan(ss,vSubArguments,1);
+        ss << "     tmp +=pow(tmp0,2) + pow(tmp1,2);\n";
+        ss <<"    }\n";
+    }
+    else
+    {
+        ss << "    int singleIndex =gid0;\n";
+        CheckAllSubArgumentIsNan(ss, vSubArguments);
+        ss << "    tmp = pow(tmp0,2) + pow(tmp1,2);\n";
+    }
+    ss << "    return tmp;\n";
+    ss << "}";
+}
 
 }}
 
diff --git a/sc/source/core/opencl/op_array.hxx b/sc/source/core/opencl/op_array.hxx
index e1f5bea..c0eff09 100644
--- a/sc/source/core/opencl/op_array.hxx
+++ b/sc/source/core/opencl/op_array.hxx
@@ -22,6 +22,14 @@ public:
     virtual std::string BinFuncName(void) const { return "SumX2MY2"; }
 };
 
+class OpSumX2PY2: public CheckVariables
+{
+public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+            const std::string sSymName, SubArguments &vSubArguments);
+    virtual std::string BinFuncName(void) const { return "SumX2PY2"; }
+};
+
 }}
 
 #endif
commit 67e2b033b1ba0938f294e853b98ce748e0fb1fa5
Author: yiming ju <yiming at multicorewareinc.com>
Date:   Tue Nov 12 17:18:50 2013 +0800

    GPU Calc: unit test cases for SUMX2MY2
    
    Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-198 BUG
    
    Change-Id: I8d3817c990b07310be31b3246af1b58b960c62d1
    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/array/SUMX2MY2.xls b/sc/qa/unit/data/xls/opencl/array/SUMX2MY2.xls
new file mode 100644
index 0000000..62d8c9a
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/array/SUMX2MY2.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 7afe2d5..bffd36d 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -230,6 +230,7 @@ public:
     void testMathFormulaConvert();
     void testMathFormulaProduct();
     void testStatisticalFormulaHypGeomDist();
+    void testArrayFormulaSumX2MY2();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -391,6 +392,7 @@ public:
     CPPUNIT_TEST(testMathFormulaConvert);
     CPPUNIT_TEST(testMathFormulaProduct);
     CPPUNIT_TEST(testStatisticalFormulaHypGeomDist);
+    CPPUNIT_TEST(testArrayFormulaSumX2MY2);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -4439,6 +4441,34 @@ void ScOpenclTest::testMathFormulaKombin()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-198]
+void ScOpenclTest:: testArrayFormulaSumX2MY2()
+{
+    if (!detectOpenCLDevice())
+        return;
+    ScDocShellRef xDocSh = loadDoc("opencl/array/SUMX2MY2.", XLS);
+    ScDocument *pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/array/SUMX2MY2.", XLS);
+    ScDocument *pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    for (SCROW i = 0; 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));
+    }
+    for (SCROW i = 20; i <= 26; ++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-199]
 void ScOpenclTest::testStatisticalFormulaHypGeomDist()
 {
@@ -4462,6 +4492,7 @@ void ScOpenclTest::testStatisticalFormulaHypGeomDist()
     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 75b28a5..38f1b13 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1461,6 +1461,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocRandom:
             case ocProduct:
             case ocHypGeomDist:
+            case ocSumX2MY2:
             // Don't change the state.
             break;
             default:
commit d470a9f978198812466832acf81ff0128c856da3
Author: yiming ju <yiming at multicorewareinc.com>
Date:   Thu Nov 14 23:14:06 2013 -0600

    GPU Calc: implemented SUMX2MY2
    
    AMLOEXT-198 FIX
    Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>
    
    Change-Id: I81f4ff0d2b11527934b2bdefba5664be6491e84a

diff --git a/sc/Library_scopencl.mk b/sc/Library_scopencl.mk
index 1f03ad5..134afb8 100644
--- a/sc/Library_scopencl.mk
+++ b/sc/Library_scopencl.mk
@@ -42,6 +42,7 @@ $(eval $(call gb_Library_add_exception_objects,scopencl,\
         sc/source/core/opencl/op_database \
         sc/source/core/opencl/op_math \
         sc/source/core/opencl/op_statistical \
+        sc/source/core/opencl/op_array \
         sc/source/core/opencl/clcc/clew \
 ))
 
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index b7b8d40..1f3871b 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -22,6 +22,7 @@
 #include "op_database.hxx"
 #include "op_math.hxx"
 #include "op_statistical.hxx"
+#include "op_array.hxx"
 #include "formulagroupcl_public.hxx"
 
 #include <list>
@@ -1476,6 +1477,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 mvSubArguments.push_back(SoPHelper(ts,
                          ft->Children[i],new OpHypGeomDist));
                 break;
+            case ocSumX2MY2:
+                mvSubArguments.push_back(SoPHelper(ts,
+                         ft->Children[i],new OpSumX2MY2));
+                break;
             case ocExternal:
                 if ( !(pChild->GetExternal().compareTo(OUString(
                     "com.sun.star.sheet.addin.Analysis.getEffect"))))
diff --git a/sc/source/core/opencl/op_array.cxx b/sc/source/core/opencl/op_array.cxx
new file mode 100644
index 0000000..ff1f54f
--- /dev/null
+++ b/sc/source/core/opencl/op_array.cxx
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "op_array.hxx"
+
+#include "formulagroup.hxx"
+#include "document.hxx"
+#include "formulacell.hxx"
+#include "tokenarray.hxx"
+#include "compiler.hxx"
+#include "interpre.hxx"
+#include "formula/vectortoken.hxx"
+#include <sstream>
+
+using namespace formula;
+
+namespace sc { namespace opencl {
+
+void OpSumX2MY2::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    {\n";
+    ss <<"     int gid0=get_global_id(0);\n";
+    ss << "    double tmp =0;\n";
+    GenTmpVariables(ss,vSubArguments);
+    if(vSubArguments[0]->GetFormulaToken()->GetType() ==
+    formula::svDoubleVectorRef)
+    {
+        FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
+        const formula::DoubleVectorRefToken*pCurDVR= dynamic_cast<const
+            formula::DoubleVectorRefToken *>(tmpCur);
+        size_t nCurWindowSize = pCurDVR->GetArrayLength() <
+        pCurDVR->GetRefRowSize() ? pCurDVR->GetArrayLength():
+        pCurDVR->GetRefRowSize() ;
+         ss << "    int i ;\n";
+         ss << "    for (i = ";
+         if (!pCurDVR->IsStartFixed() && pCurDVR->IsEndFixed()) {
+            ss << "gid0; i < "<< nCurWindowSize <<"; i++)\n";
+         } else if (pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed()) {
+            ss << "0; i < gid0+"<< nCurWindowSize <<"; i++)\n";
+         } else {
+            ss << "0; i < "<< nCurWindowSize <<"; i++)\n";
+         }
+         ss << "    {\n";
+         if(!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
+         {
+            ss << "    int doubleIndex =i+gid0;\n";
+         }else
+         {
+            ss << "    int doubleIndex =i;\n";
+         }
+
+        CheckSubArgumentIsNan(ss,vSubArguments,0);
+        CheckSubArgumentIsNan(ss,vSubArguments,1);
+        ss << "     tmp +=pow(tmp0,2) - pow(tmp1,2);\n";
+        ss <<"    }\n";
+    }
+    else
+    {
+        ss << "    int singleIndex =gid0;\n";
+        CheckAllSubArgumentIsNan(ss, vSubArguments);
+        ss << "    tmp = pow(tmp0,2) - pow(tmp1,2);\n";
+    }
+    ss << "return tmp;\n";
+    ss << "}";
+}
+
+
+}}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/opencl/op_array.hxx b/sc/source/core/opencl/op_array.hxx
new file mode 100644
index 0000000..e1f5bea
--- /dev/null
+++ b/sc/source/core/opencl/op_array.hxx
@@ -0,0 +1,29 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef SC_OPENCL_OP_ARRAY_HXX
+#define SC_OPENCL_OP_ARRAY_HXX
+
+#include "opbase.hxx"
+
+namespace sc { namespace opencl {
+
+class OpSumX2MY2: public CheckVariables
+{
+public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+            const std::string sSymName, SubArguments &vSubArguments);
+    virtual std::string BinFuncName(void) const { return "SumX2MY2"; }
+};
+
+}}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 0b199159169d02dfa31df271932e02404de94899
Author: mingli <mingli at multicorewareinc.com>
Date:   Tue Nov 12 16:54:51 2013 +0800

    GPU Calc: unit test cases for HYPGEOMDIST
    
    Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-199 BUG
    
    Change-Id: Ibad56aaa79c705e39b0ccad7a6b72955feeb4b4c
    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/HypGeomDist.xls b/sc/qa/unit/data/xls/opencl/statistical/HypGeomDist.xls
new file mode 100644
index 0000000..551cf24
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/statistical/HypGeomDist.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index f5295ba..7afe2d5 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -229,6 +229,7 @@ public:
     void testMathFormulaRandom();
     void testMathFormulaConvert();
     void testMathFormulaProduct();
+    void testStatisticalFormulaHypGeomDist();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -389,6 +390,7 @@ public:
     CPPUNIT_TEST(testMathFormulaRandom);
     CPPUNIT_TEST(testMathFormulaConvert);
     CPPUNIT_TEST(testMathFormulaProduct);
+    CPPUNIT_TEST(testStatisticalFormulaHypGeomDist);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -4437,6 +4439,29 @@ void ScOpenclTest::testMathFormulaKombin()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-199]
+void ScOpenclTest::testStatisticalFormulaHypGeomDist()
+{
+    if (!detectOpenCLDevice())
+        return;
+    ScDocShellRef xDocSh = loadDoc("opencl/statistical/HypGeomDist.", XLS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/statistical/HypGeomDist.", 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));
+    }
+    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 750c60c..75b28a5 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1460,6 +1460,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocPi:
             case ocRandom:
             case ocProduct:
+            case ocHypGeomDist:
             // Don't change the state.
             break;
             default:
commit 2354714c542666d96d080e28ea293db016aaad58
Author: mingli <mingli at multicorewareinc.com>
Date:   Tue Nov 12 17:00:57 2013 +0800

    GPU Calc: implemented for HYPGEOMDIST
    
    AMLOEXT-199 FIX
    
    Change-Id: I2f621a4f9e0659d1f0be8b9a0bb9c32352b47c2e
    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 99693e7..b7b8d40 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1472,6 +1472,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 mvSubArguments.push_back(SoPHelper(ts,
                          ft->Children[i], new OpProduct));
                 break;
+            case ocHypGeomDist:
+                mvSubArguments.push_back(SoPHelper(ts,
+                         ft->Children[i],new OpHypGeomDist));
+                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 b71bc2a..ddad803 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -6412,6 +6412,129 @@ void OpDevSq::GenSlidingWindowFunction(std::stringstream& ss,
         ss << "    return vSum;\n";
         ss << "}";
 }
+void OpHypGeomDist::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 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";
+#endif
+            } else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed()) {
+#ifdef  ISNAN
+                ss << "0; i < " << pDVR->GetArrayLength();
+                ss << " && 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 ";
+#endif
+            }
+            else {
+#ifdef  ISNAN
+                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<<"=";
+            ss <<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<<"=";
+            ss <<vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss << ";\n";
+#endif
+        }
+    }
+    ss << "    double N1=floor(arg3);\n"
+    "    double M1=floor(arg2);\n"
+    "    double n1=floor(arg1);\n"
+    "    double x1=floor(arg0);\n"
+    "    double num[9],out[9];\n"
+    "    double PI = 3.1415926535897932384626433832795;\n"
+    "    double tmp,sum;\n"
+    "    if( (x1 < 0.0) || (n1 < x1) || (M1 < x1) || (N1 < n1) ||"
+    "(N1 < M1) || (x1 < n1 - N1 + M1) )\n"
+    "    {\n"
+    "        tmp = DBL_MIN;\n"
+    "        return tmp;\n"
+    "    }\n"
+    "    num[0]=M1;\n"
+    "    num[1]=x1;\n"
+    "    num[2]=M1-x1;\n"
+    "    num[3]=N1-M1;\n"
+    "    num[4]=n1-x1;\n"
+    "    num[5]=N1-M1-n1+x1;\n"
+    "    num[6]=N1;\n"
+    "    num[7]=n1;\n"
+    "    num[8]=N1-n1;\n"
+    "    for(int i=0;i<9;i++)\n"
+    "    {\n"
+    "        if(num[i]<171)\n"
+    "        {\n"
+    "            if(num[i]==0)\n"
+    "                out[i]=0;\n"
+    "            else\n"
+    "                out[i]=log(tgamma(num[i])*num[i]);\n"
+    "        }\n"
+    "        else\n"
+    "            out[i]=0.5*log(2.0*PI)+(num[i]+0.5)*log(num[i])-num[i]+"
+    "(1.0/12.0/num[i]-1.0/360/(num[i]*num[i]*num[i]));\n"
+    "    }\n";
+    ss << "    sum=out[0]+out[3]+out[7]+out[8]-out[1]-out[2]-out[4]-out[5]-out[6];\n";
+    ss << "    tmp=exp(sum);\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 900c189..9f8f54a 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -302,6 +302,12 @@ public:
     void BinInlineFun(std::set<std::string>& decls,std::set<std::string>& funs);
     virtual std::string BinFuncName(void) const { return "GammaDist"; }
 };
+class OpHypGeomDist:public Normal{
+    public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+            const std::string sSymName, SubArguments &vSubArguments);
+    virtual std::string BinFuncName(void) const { return "OpHypGeomDist"; }
+};
 class OpChiDist:public Normal{
     public:
     virtual void GenSlidingWindowFunction(std::stringstream &ss,
commit 66ded6ba639ed8f14015db88367c6451ac54eece
Author: dechuang <dechuang at multicorewareinc.com>
Date:   Tue Nov 12 16:37:10 2013 +0800

    GPU Calc: unit test cases for PRODUCT
    
    Need macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-193 BUG
    
    Change-Id: I7d866bebf2bd3d01a8ea0643561f918581af2c93
    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/math/product.xls b/sc/qa/unit/data/xls/opencl/math/product.xls
new file mode 100644
index 0000000..34520f7
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/math/product.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index c4d028e..f5295ba 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -228,6 +228,7 @@ public:
     void testMathFormulaPi();
     void testMathFormulaRandom();
     void testMathFormulaConvert();
+    void testMathFormulaProduct();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -387,6 +388,7 @@ public:
     CPPUNIT_TEST(testMathFormulaPi);
     CPPUNIT_TEST(testMathFormulaRandom);
     CPPUNIT_TEST(testMathFormulaConvert);
+    CPPUNIT_TEST(testMathFormulaProduct);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -4390,6 +4392,28 @@ void ScOpenclTest::testStatisticalFormulaBinomDist()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-193]
+void ScOpenclTest::testMathFormulaProduct()
+{
+    if (!detectOpenCLDevice())
+        return;
+    ScDocShellRef xDocSh = loadDoc("opencl/math/product.", XLS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/math/product.", XLS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    for (SCROW i = 0; i <= 3; ++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-194]
 void ScOpenclTest::testMathFormulaKombin()
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index d2212dc..750c60c 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1459,6 +1459,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocZTest:
             case ocPi:
             case ocRandom:
+            case ocProduct:
             // Don't change the state.
             break;
             default:
commit 1de904adc62c7d6cd29ecf248dbe941a51e09646
Author: dechuang <dechuang at multicorewareinc.com>
Date:   Tue Nov 12 16:47:21 2013 +0800

    GPU Calc: implemented PRODUCT
    
    AMLOEXT-193 FIX
    
    Change-Id: Iaa1ca2f02e44621c8acbb07f74a059a9280f489d
    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 cf727f4..99693e7 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1468,6 +1468,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 SubArgument(new DynamicKernelRandomArgument(ts,
                 ft->Children[i])));
                 break;
+            case ocProduct:
+                mvSubArguments.push_back(SoPHelper(ts,
+                         ft->Children[i], new OpProduct));
+                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 da9bdfd..dc5d7d4 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1912,6 +1912,84 @@ void OpConvert::GenSlidingWindowFunction(
 
 }
 
+void OpProduct::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 i = 0;\n";
+    ss << "    double product=0.0;\n\n";
+    char sArgNoI[5];
+    for (unsigned i = 0; i < vSubArguments.size(); i++)
+    {
+        sprintf(sArgNoI,"%d",i);
+        ss << std::string("    double arg")+sArgNoI+";\n";
+        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 << std::string("    arg")+sArgNoI+" = ";
+            ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss <<";\n";
+#ifdef ISNAN
+            ss << std::string("    if(isNan(arg")+sArgNoI+")||((gid0+i)>=";
+            ss << pDVR->GetArrayLength();
+            ss << "))\n";
+            ss << "    {\n";
+            ss << std::string("        arg")+sArgNoI+" = 0;\n";
+            ss << "    }\n";
+#endif
+            ss << std::string("    product = arg")+sArgNoI+";\n";
+            ss << "    for (i = ";
+            ss << "1; i < "<< nCurWindowSize << "; i++)\n";
+            ss << "    {\n";
+            ss << std::string("        arg")+sArgNoI+" = ";
+            ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss << ";\n";
+#ifdef ISNAN
+            ss <<std::string("        if(isNan(arg")+sArgNoI+")||((gid0+i)>=";
+            ss << pDVR->GetArrayLength();
+            ss << "))\n";
+            ss << "        {\n";
+            ss << std::string("            arg")+sArgNoI+" = 0;\n";
+            ss << "        }\n";
+#endif
+            ss << std::string("        product*=arg")+sArgNoI+";\n";
+            ss << "    }\n";
+            }
+            else if (pCur->GetType() == formula::svSingleVectorRef)
+            {
+#ifdef  ISNAN
+                ss << std::string("    arg")+sArgNoI+" = ";
+                ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+                ss << ";\n";
+                ss << std::string("    product*=arg")+sArgNoI+";\n";
+#endif
+            }
+            else if (pCur->GetType() == formula::svDouble)
+            {
+#ifdef  ISNAN
+                ss << std::string("    arg")+sArgNoI+" = ";
+                ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+                ss << ";\n";
+                ss << std::string("    product*=arg")+sArgNoI+";\n";
+#endif
+            }
+        }
+        ss << "    return product;\n";
+        ss << "}";
+}
 
 }}
 
diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx
index cd9b9f7..01cbc82 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -320,6 +320,13 @@ public:
 
     virtual std::string BinFuncName(void) const { return "Mod"; }
 };
+class OpProduct: public Normal
+{
+public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+        const std::string sSymName, SubArguments &vSubArguments);
+    virtual std::string BinFuncName(void) const { return "Product"; }
+};
 class OpSqrtPi: public Normal
 {
 public:
commit 8bf3864069cf67ae97299c4e0e042b922a45a989
Author: dechuang <dechuang at multicorewareinc.com>
Date:   Tue Nov 12 16:21:10 2013 +0800

    GPU Calc: unit test cases for CONVERT
    
    Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-175 BUG
    
    Change-Id: If490d33b86b249f4f88cfec1d82131b9967942d1
    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/math/convert.xls b/sc/qa/unit/data/xls/opencl/math/convert.xls
new file mode 100644
index 0000000..4e2f206
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/math/convert.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 0fda4f8..c4d028e 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -227,6 +227,7 @@ public:
     void testStatisticalFormulaZTest();
     void testMathFormulaPi();
     void testMathFormulaRandom();
+    void testMathFormulaConvert();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -385,6 +386,7 @@ public:
     CPPUNIT_TEST(testStatisticalFormulaZTest);
     CPPUNIT_TEST(testMathFormulaPi);
     CPPUNIT_TEST(testMathFormulaRandom);
+    CPPUNIT_TEST(testMathFormulaConvert);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -4058,7 +4060,28 @@ void ScOpenclTest::testStatisticalFormulaChiInv()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
-
+//[AMLOEXT-175]
+void ScOpenclTest::testMathFormulaConvert()
+{
+    if (!detectOpenCLDevice())
+        return;
+    ScDocShellRef xDocSh = loadDoc("opencl/math/convert.", XLS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/math/convert.", XLS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    for (SCROW i = 0; i <= 3; ++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-176 ]
 void ScOpenclTest::testMathCountIfsFormula()
 {
commit ba6584719fb8b1b1fe60ca96fd59db318ae01c80
Author: dechuang <dechuang at multicorewareinc.com>
Date:   Tue Nov 12 16:28:50 2013 +0800

    GPU Calc: implemented for CONVERT
    
    AMLOEXT-175 FIX
    
    Change-Id: I5f559444019534ce62a056fe16c5880901158b61
    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 aeec18f..cf727f4 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1663,6 +1663,12 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                     mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],
                         new OpSqrtPi));
                 }
+                else if ( !(pChild->GetExternal().compareTo(OUString(
+                     "com.sun.star.sheet.addin.Analysis.getConvert"))))
+                {
+                    mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],
+                        new OpConvert));
+                }
                 break;
             default:
                 throw UnhandledToken(pChild, "unhandled opcode");
diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx
index 73c4c45..da9bdfd 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1851,7 +1851,66 @@ void OpKombin::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "    return result;                        \n";
     ss << "}                                         \n";
 }
+void OpConvert::GenSlidingWindowFunction(
+    std::stringstream &ss, const std::string sSymName,
+    SubArguments &vSubArguments)
+{
+    int arg1=vSubArguments[1]->GetFormulaToken()->GetString().\
+        getString().toAsciiUpperCase().hashCode();
+    int arg2=vSubArguments[2]->GetFormulaToken()->GetString().\
+        getString().toAsciiUpperCase().hashCode();
+    if( !((arg1==5584&&arg2==108)||
+        (arg1==108&&arg2==5584)||
+        (arg1==5665&&arg2==268206)||
+        (arg1==268206&&arg2==5665)) )
+        throw Unhandled();
 
+    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==5584U&&arg2==108U)\n";
+    ss<<"        return arg0*1000.0;\n";
+    ss<<"    else if(arg1==108U&&arg2==3385U)\n";
+    ss<<"        return arg0/1000.0;\n";
+    ss<<"    else if(arg1==5665U&&arg2==268206U)\n";
+    ss<<"        return arg0*60.0;\n";
+    ss<<"    else if(arg1==268206U&&arg2==5665U)\n";
+    ss<<"        return arg0/60.0;\n";
+    ss<<"    else\n";
+    ss<<"        return -9999999999;\n";
+    ss << "}\n";
+
+}
 
 
 }}
diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx
index d458072..cd9b9f7 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -283,6 +283,13 @@ public:
             const std::string sSymName, SubArguments &vSubArguments);
     virtual std::string BinFuncName(void) const { return "Log10"; }
 };
+class OpConvert: public Normal
+{
+public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+        const std::string sSymName, SubArguments &vSubArguments);
+    virtual std::string BinFuncName(void) const { return "Convert"; }
+};
 class OpEven: public Normal
 {
 public:
commit 1c6127e1307fdf4f699c852373797cebb051a125
Author: zhenyu yuan <zhenyuyuan at multicorewareinc.com>
Date:   Tue Nov 12 15:43:45 2013 +0800

    GPU Calc: unit test cases for RAND
    
    Need to enable macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-197 BUG
    
    Change-Id: Iadf1d77fcef120e1b4a84ba3b08150297cf46608
    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/math/random.xls b/sc/qa/unit/data/xls/opencl/math/random.xls
new file mode 100644
index 0000000..8712263
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/math/random.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 967b03e..0fda4f8 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -226,6 +226,7 @@ public:
     void testStatisticalFormulaSTEYX();
     void testStatisticalFormulaZTest();
     void testMathFormulaPi();
+    void testMathFormulaRandom();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -383,6 +384,7 @@ public:
     CPPUNIT_TEST(testStatisticalFormulaSTEYX);
     CPPUNIT_TEST(testStatisticalFormulaZTest);
     CPPUNIT_TEST(testMathFormulaPi);
+    CPPUNIT_TEST(testMathFormulaRandom);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -720,6 +722,30 @@ void ScOpenclTest::testMathFormulaPi()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-197]
+void ScOpenclTest::testMathFormulaRandom()
+{
+    if (!detectOpenCLDevice())
+        return;
+
+    ScDocShellRef xDocSh = loadDoc("opencl/math/random.", XLS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/math/random.", XLS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    for (SCROW i = 0; i <= 15; ++i)
+    {
+        double fLibre = pDoc->GetValue(ScAddress(0,i,0));
+        double fExcel = pDocRes->GetValue(ScAddress(0,i,0));
+        //because the random numbers will always change,so give the test "true"
+        CPPUNIT_ASSERT(true);
+    }
+    xDocSh->DoClose();
+    xDocShRes->DoClose();
+}
 void ScOpenclTest::testFinacialFormula()
 {
     if (!detectOpenCLDevice())
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index ebcd4ea..d2212dc 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1458,6 +1458,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocSTEYX:
             case ocZTest:
             case ocPi:
+            case ocRandom:
             // Don't change the state.
             break;
             default:
commit 70eadc4eaa4e6b05388cca1bb9f273df097272d4
Author: zhenyu yuan <zhenyuyuan at multicorewareinc.com>
Date:   Tue Nov 12 15:55:06 2013 +0800

    GPU Calc: implemented RAND
    
    AMLOEXT-197 FIX
    
    Change-Id: Idf99d66217516aa2f57801a94b2e38d0409d4262
    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 51f6820..aeec18f 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -232,6 +232,47 @@ public:
     }
 };
 
+class DynamicKernelRandomArgument: public DynamicKernelArgument
+{
+public:
+    DynamicKernelRandomArgument(const std::string &s,
+        FormulaTreeNodeRef ft):
+            DynamicKernelArgument(s, ft) {}
+    /// Generate declaration
+    virtual void GenDecl(std::stringstream &ss) const
+    {
+        ss << "double " << mSymName;
+    }
+    virtual void GenDeclRef(std::stringstream &ss) const
+    {
+        double d;
+        srand((unsigned)time(NULL));
+        d=((double)rand())/RAND_MAX;
+        ss << d;
+    }
+    virtual void GenSlidingWindowDecl(std::stringstream &ss) const
+    {
+        GenDecl(ss);
+    }
+    virtual std::string GenSlidingWindowDeclRef(bool=false) const
+    {
+        return mSymName;
+    }
+    virtual size_t GetWindowSize(void) const
+    {
+        return 1;
+    }
+    /// Create buffer and pass the buffer to a given kernel
+    virtual size_t Marshal(cl_kernel k, int argno, int)
+    {
+        double tmp = 0.0;
+        // Pass the scalar result back to the rest of the formula kernel
+        cl_int err = clSetKernelArg(k, argno, sizeof(double), (void*)&tmp);
+        if (CL_SUCCESS != err)
+            throw OpenCLError(err);
+        return 1;
+    }
+};
 
 class DynamicKernelStringArgument: public DynamicKernelArgument
 {
@@ -1422,6 +1463,11 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 SubArgument(new DynamicKernelPiArgument(ts,
                 ft->Children[i])));
                 break;
+            case ocRandom:
+                mvSubArguments.push_back(
+                SubArgument(new DynamicKernelRandomArgument(ts,
+                ft->Children[i])));
+                break;
             case ocExternal:
                 if ( !(pChild->GetExternal().compareTo(OUString(
                     "com.sun.star.sheet.addin.Analysis.getEffect"))))
commit 76a4dd60c5ce938508e4f44d8473aa0c3a0c58ed
Author: zhenyu yuan <zhenyuyuan at multicorewareinc.com>
Date:   Tue Nov 12 15:23:10 2013 +0800

    GPU Calc: unit test cases for PI
    
    Need to turn on NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-196 BUG
    
    Change-Id: Ia60cb2739ea6485e31c4f81b7813798ba97a99f9
    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/math/pi.xls b/sc/qa/unit/data/xls/opencl/math/pi.xls
new file mode 100644
index 0000000..c0a824d
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/math/pi.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index d71f0ef..967b03e 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -225,6 +225,7 @@ public:
     void testStatisticalFormulaSlope();
     void testStatisticalFormulaSTEYX();
     void testStatisticalFormulaZTest();
+    void testMathFormulaPi();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -381,6 +382,7 @@ public:
     CPPUNIT_TEST(testStatisticalFormulaSlope);
     CPPUNIT_TEST(testStatisticalFormulaSTEYX);
     CPPUNIT_TEST(testStatisticalFormulaZTest);
+    CPPUNIT_TEST(testMathFormulaPi);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -695,7 +697,29 @@ void ScOpenclTest::testMathFormulaSinh()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-196]
+void ScOpenclTest::testMathFormulaPi()
+{
+    if (!detectOpenCLDevice())
+        return;
 
+    ScDocShellRef xDocSh = loadDoc("opencl/math/pi.", XLS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/math/pi.", XLS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    for (SCROW i = 0; i <= 15; ++i)
+    {
+        double fLibre = pDoc->GetValue(ScAddress(0,i,0));
+        double fExcel = pDocRes->GetValue(ScAddress(0,i,0));
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+    }
+    xDocSh->DoClose();
+    xDocShRes->DoClose();
+}
 void ScOpenclTest::testFinacialFormula()
 {
     if (!detectOpenCLDevice())
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 3c26e3a..ebcd4ea 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1457,6 +1457,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocSlope:
             case ocSTEYX:
             case ocZTest:
+            case ocPi:
             // Don't change the state.
             break;
             default:
commit 0115152dacd10bc4029c585f6fe55bb7695f04ab
Author: zhenyu yuan <zhenyuyuan at multicorewareinc.com>
Date:   Tue Nov 12 15:35:15 2013 +0800

    GPU Calc: implemented PI
    
    AMLOEXT-196 FIX
    
    Change-Id: Ic9328d4cc7650bb2270e8b77969502bd3f4f49ba
    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 3666822..51f6820 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -193,6 +193,46 @@ public:
     }
 };
 
+class DynamicKernelPiArgument: public DynamicKernelArgument
+{
+public:
+    DynamicKernelPiArgument(const std::string &s,
+        FormulaTreeNodeRef ft):
+            DynamicKernelArgument(s, ft) {}
+    /// Generate declaration
+    virtual void GenDecl(std::stringstream &ss) const
+    {
+        ss << "double " << mSymName;
+    }
+    virtual void GenDeclRef(std::stringstream &ss) const
+    {
+        ss << "3.14159265358979";
+    }
+    virtual void GenSlidingWindowDecl(std::stringstream &ss) const
+    {
+        GenDecl(ss);
+    }
+    virtual std::string GenSlidingWindowDeclRef(bool=false) const
+    {
+        return mSymName;
+    }
+    virtual size_t GetWindowSize(void) const
+    {
+        return 1;
+    }
+    /// Create buffer and pass the buffer to a given kernel
+    virtual size_t Marshal(cl_kernel k, int argno, int)
+    {
+        double tmp = 0.0;
+        // Pass the scalar result back to the rest of the formula kernel
+        cl_int err = clSetKernelArg(k, argno, sizeof(double), (void*)&tmp);
+        if (CL_SUCCESS != err)
+            throw OpenCLError(err);
+        return 1;
+    }
+};
+
+
 class DynamicKernelStringArgument: public DynamicKernelArgument
 {
 public:
@@ -1377,6 +1417,11 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 mvSubArguments.push_back(SoPHelper(ts,
                          ft->Children[i], new OpZTest));
                 break;
+            case ocPi:
+                mvSubArguments.push_back(
+                SubArgument(new DynamicKernelPiArgument(ts,
+                ft->Children[i])));
+                break;
             case ocExternal:
                 if ( !(pChild->GetExternal().compareTo(OUString(
                     "com.sun.star.sheet.addin.Analysis.getEffect"))))
commit 9d98f56d956cb08e67c15a8d75ef1e5df4588ba5
Author: shiming zhang <shiming at multicorewareinc.com>
Date:   Tue Nov 12 15:06:55 2013 +0800

    GPU Calc: unit test cases for ZTEST
    
    Need to enable NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-188 BUG
    
    Change-Id: I79cdfdd7f73cc3283bfa1cdabc00173422c953b4
    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/ZTest.xls b/sc/qa/unit/data/xls/opencl/statistical/ZTest.xls
new file mode 100644
index 0000000..115fdbc
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/statistical/ZTest.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 9403156..d71f0ef 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -224,6 +224,7 @@ public:
     void testStatisticalFormulaStDev();
     void testStatisticalFormulaSlope();
     void testStatisticalFormulaSTEYX();
+    void testStatisticalFormulaZTest();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -379,6 +380,7 @@ public:
     CPPUNIT_TEST(testStatisticalFormulaStDev);
     CPPUNIT_TEST(testStatisticalFormulaSlope);
     CPPUNIT_TEST(testStatisticalFormulaSTEYX);
+    CPPUNIT_TEST(testStatisticalFormulaZTest);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -4267,6 +4269,31 @@ void ScOpenclTest::testStatisticalFormulaSTEYX()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-188]
+void ScOpenclTest::testStatisticalFormulaZTest()
+{
+    if (!detectOpenCLDevice())
+        return;
+
+    ScDocShellRef xDocSh = loadDoc("opencl/statistical/ZTest.", XLS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+
+    ScDocShellRef xDocShRes = loadDoc("opencl/statistical/ZTest.", XLS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    // Check the results of formula cells in the shared formula range.
+    for (SCROW i = 1; i <= 20; ++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-192]
 void ScOpenclTest::testStatisticalFormulaBinomDist()
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 3e2088e..3c26e3a 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1456,6 +1456,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocStDev:
             case ocSlope:
             case ocSTEYX:
+            case ocZTest:
             // Don't change the state.
             break;
             default:
commit 906e1c9af7af41122034e36406622d9db7d68502
Author: shiming zhang <shiming at multicorewareinc.com>
Date:   Tue Nov 12 15:16:36 2013 +0800

    GPU Calc: implemented ZTEST
    
    AMLOEXT-188 FIX
    
    Change-Id: Ib1dc158d13cf80dbb23621d0fce33f10d1baba2a
    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 9a718cc..3666822 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1373,6 +1373,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 mvSubArguments.push_back(SoPHelper(ts,
                          ft->Children[i], new OpSTEYX));
                 break;
+            case ocZTest:
+                mvSubArguments.push_back(SoPHelper(ts,
+                         ft->Children[i], new OpZTest));
+                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 9338164..b71bc2a 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -254,6 +254,312 @@ void OpVar::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "        return vSum / (fCount - 1.0);\n";
     ss << "}\n";
 }
+void OpZTest::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 fSum=0.0;\n";
+    ss << "    double fSumSqr=0.0;\n";
+    ss << "    double mue=0.0;\n";
+    ss << "    double fCount=0.0;\n";
+    ss << "    double arg=0.0;\n";
+    ss << "    double sigma=0.0;\n";
+    ss << "    double mu=0.0;\n";
+    if(vSubArguments.size() == 1 || vSubArguments.size() == 0)
+    {
+        ss << "    return DBL_MAX;\n";
+        ss << "}\n";
+        return ;
+    }
+    else if(vSubArguments.size() == 2)
+    {
+        FormulaToken *pCur = vSubArguments[0]->GetFormulaToken();
+        FormulaToken *pCur1 = vSubArguments[1]->GetFormulaToken();
+        assert(pCur);
+        assert(pCur1);
+        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";
+                ss << "    {\n";
+#else
+                ss << "gid0; i < "<< nCurWindowSize << "; i++)\n";
+                ss << "    {\n";
+#endif
+            }
+            else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+            {
+#ifdef  ISNAN
+                ss << "0; i < " << pDVR->GetArrayLength();
+                ss << " && i < gid0+"<< nCurWindowSize << "; i++)\n";
+                ss << "    {\n";
+#else
+                ss << "0; i < gid0+"<< nCurWindowSize << "; i++)\n";
+                ss << "    {\n";
+#endif
+            }
+            else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+            {
+#ifdef  ISNAN
+                ss << "0; i + gid0 < " << pDVR->GetArrayLength();
+                ss << " &&  i < "<< nCurWindowSize << "; i++)\n";
+                ss << "    {\n";
+#else
+                ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+                ss << "    {\n";
+#endif
+            }
+            else
+            {
+#ifdef  ISNAN
+                ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+                ss << "    {\n";
+#else
+                ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+                ss << "    {\n";
+#endif
+            }
+
+            ss << "        arg = ";
+            ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
+#ifdef  ISNAN
+            ss << "        if (isNan(arg))\n";
+            ss << "            continue;\n";
+#endif
+            ss << "        fSum += arg;\n";
+            ss << "        fSumSqr += arg*arg;\n";
+            ss << "        fCount += 1;\n";
+            ss << "    }\n";
+            ss << "    if(fCount<=1.0)\n";
+            ss << "        return DBL_MAX;\n";
+            ss << "    mue=fSum/fCount;\n";
+            ss << "    sigma=(fSumSqr-fSum*fSum/fCount)/(fCount-1.0);\n";
+        }
+        else
+        {
+            ss << "    return DBL_MAX;\n";
+            ss << "}\n";
+            return ;
+        }
+        if(ocPush==vSubArguments[1]->GetFormulaToken()->GetOpCode())
+        {
+            if(pCur1->GetType() == formula::svSingleVectorRef)
+            {
+                const formula::SingleVectorRefToken* pSVR =
+                    dynamic_cast< const formula::
+                        SingleVectorRefToken* >(pCur1);
+                assert(pSVR);
+#ifdef  ISNAN
+                ss << "    if (gid0 < " << pSVR->GetArrayLength() << ")\n";
+                ss << "    {\n";
+                ss << "        if (isNan(";
+                ss << vSubArguments[1]->GenSlidingWindowDeclRef() << "))\n";
+                ss << "            mu=0.0;\n";
+                ss << "        else\n";
+#endif
+                ss << "            mu=" ;
+                ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
+#ifdef ISNAN
+                ss << "    }\n";
+#endif
+
+            }
+            else if(pCur1->GetType() == formula::svDouble)
+            {
+                ss << "    mu = " << pCur1->GetDouble() << ";\n";
+            }
+            else
+            {
+                ss << "    return DBL_MAX;\n";
+                ss << "}\n";
+                return ;
+            }
+        }
+        else
+        {
+            ss << "    mu=" ;
+            ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
+        }
+        ss << "    return 0.5-(0.5 *erfc(-((mue-mu)/sqrt(sigma/fCount))";
+        ss << "* 0.7071067811865475)-0.5);\n";
+        ss << "}\n";
+        return ;
+    }
+    else
+    {
+        FormulaToken *pCur = vSubArguments[0]->GetFormulaToken();
+        FormulaToken *pCur1 = vSubArguments[1]->GetFormulaToken();
+        FormulaToken *pCur2 = vSubArguments[2]->GetFormulaToken();
+        assert(pCur);
+        assert(pCur1);
+        assert(pCur2);
+        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";
+                ss << "    {\n";
+#else
+                ss << "gid0; i < "<< nCurWindowSize << "; i++)\n";
+                ss << "    {\n";
+#endif
+            }
+            else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+            {
+#ifdef  ISNAN
+                ss << "0; i < " << pDVR->GetArrayLength();
+                ss << " && i < gid0+"<< nCurWindowSize << "; i++)\n";
+                ss << "    {\n";
+#else
+                ss << "0; i < gid0+"<< nCurWindowSize << "; i++)\n";
+                ss << "    {\n";
+#endif
+            }
+            else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+            {
+#ifdef  ISNAN
+                ss << "0; i + gid0 < " << pDVR->GetArrayLength();
+                ss << " &&  i < "<< nCurWindowSize << "; i++)\n";
+                ss << "    {\n";
+#else
+                ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+                ss << "    {\n";
+#endif
+            }
+            else
+            {
+#ifdef  ISNAN
+                ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+                ss << "    {\n";
+#else
+                ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+                ss << "    {\n";
+#endif
+            }
+            ss << "        arg = ";
+            ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
+#ifdef  ISNAN
+            ss << "        if (isNan(arg))\n";
+            ss << "            continue;\n";
+#endif
+            ss << "        fSum += arg;\n";
+            ss << "        fSumSqr += arg*arg;\n";
+            ss << "        fCount += 1;\n";
+            ss << "    }\n";
+            ss << "    if(fCount<=1.0)\n";
+            ss << "        return DBL_MAX;\n";
+            ss << "    mue=fSum/fCount;\n";
+        }
+        else
+        {
+            ss << "    return DBL_MAX;\n";
+            ss << "}\n";
+            return ;
+        }
+        if(ocPush==vSubArguments[1]->GetFormulaToken()->GetOpCode())
+        {
+            if(pCur1->GetType() == formula::svSingleVectorRef)
+            {
+                const formula::SingleVectorRefToken* pSVR1 =
+                    dynamic_cast< const formula::
+                        SingleVectorRefToken* >(pCur1);
+                assert(pSVR1);
+#ifdef  ISNAN
+                ss << "    if (gid0 < " << pSVR1->GetArrayLength() << ")\n";
+                ss << "    {\n";
+                ss << "        if (isNan(";
+                ss << vSubArguments[1]->GenSlidingWindowDeclRef() << "))\n";
+                ss << "            mu=0.0;\n";
+                ss << "        else\n";
+#endif
+                ss << "            mu=" ;
+                ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
+#ifdef ISNAN
+                ss << "    }\n";
+#endif
+            }
+            else if(pCur1->GetType() == formula::svDouble)
+            {
+                ss << "    mu = " << pCur1->GetDouble() << ";\n";
+            }
+            else
+            {
+                ss << "    return DBL_MAX;\n";
+                ss << "}\n";
+                return ;
+            }
+        }
+        else
+        {
+            ss << "    mu=" ;
+            ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
+        }
+        if(ocPush==vSubArguments[2]->GetFormulaToken()->GetOpCode())
+        {
+            if(pCur2->GetType() == formula::svSingleVectorRef)
+            {
+                const formula::SingleVectorRefToken* pSVR2 =
+                    dynamic_cast< const formula::
+                        SingleVectorRefToken* >(pCur2);
+                assert(pSVR2);
+#ifdef  ISNAN
+                ss << "    if (gid0 < " << pSVR2->GetArrayLength() << ")\n";
+                ss << "    {\n";
+                ss << "        if (isNan(";
+                ss << vSubArguments[2]->GenSlidingWindowDeclRef() << "))\n";
+                ss << "            sigma=0.0;\n";
+                ss << "        else\n";
+#endif
+                ss << "            sigma=" ;
+                ss << vSubArguments[2]->GenSlidingWindowDeclRef() << ";\n";
+#ifdef ISNAN
+                ss << "    }\n";
+#endif
+            }
+            else if(pCur2->GetType() == formula::svDouble)
+            {
+                ss << "    sigma = " << pCur2->GetDouble() << ";\n";
+            }
+            else
+            {
+                ss << "    return DBL_MAX;\n";
+                ss << "}\n";
+                return ;
+            }
+        }
+        else
+        {
+            ss << "    sigma=" ;
+            ss << vSubArguments[2]->GenSlidingWindowDeclRef() << ";\n";
+        }
+        ss << "    return 0.5-(0.5 *erfc(-((mue-mu)*sqrt(fCount)/sigma)";
+        ss << " * 0.7071067811865475)-0.5);\n";
+        ss << "}\n";
+    }
+}
+
 void OpVarP::GenSlidingWindowFunction(std::stringstream &ss,
             const std::string sSymName, SubArguments &vSubArguments)
 {
diff --git a/sc/source/core/opencl/op_statistical.hxx b/sc/source/core/opencl/op_statistical.hxx
index 497f782..900c189 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -49,6 +49,13 @@ public:
             const std::string sSymName, SubArguments &vSubArguments);
     virtual std::string BinFuncName(void) const { return "VarP"; }
 };
+class OpZTest: public Normal
+{
+public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+            const std::string sSymName, SubArguments &vSubArguments);
+    virtual std::string BinFuncName(void) const { return "ZTest"; }
+};
 class OpStDev: public Normal
 {
 public:
commit a9283028c255c8d76734f20269eb5aae01cb6a6d
Author: shiming zhang <shiming at multicorewareinc.com>
Date:   Tue Nov 12 14:46:33 2013 +0800

    GPU Calc: unit test cases for STEYX
    
    Need to turn on NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-187 BUG
    
    Change-Id: I23f774839d5105ebe729a1cd7df98ef22caa4b70
    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/STEYX.xls b/sc/qa/unit/data/xls/opencl/statistical/STEYX.xls
new file mode 100644
index 0000000..5deb739
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/statistical/STEYX.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 521d69e..9403156 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -223,6 +223,7 @@ public:
     void testStatisticalFormulaDevSq();
     void testStatisticalFormulaStDev();
     void testStatisticalFormulaSlope();
+    void testStatisticalFormulaSTEYX();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -377,6 +378,7 @@ public:
     CPPUNIT_TEST(testStatisticalFormulaDevSq);
     CPPUNIT_TEST(testStatisticalFormulaStDev);
     CPPUNIT_TEST(testStatisticalFormulaSlope);
+    CPPUNIT_TEST(testStatisticalFormulaSTEYX);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -4240,6 +4242,31 @@ void ScOpenclTest::testStatisticalFormulaSlope()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-187]
+void ScOpenclTest::testStatisticalFormulaSTEYX()
+{
+    if (!detectOpenCLDevice())
+        return;
+
+    ScDocShellRef xDocSh = loadDoc("opencl/statistical/STEYX.", XLS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+
+    ScDocShellRef xDocShRes = loadDoc("opencl/statistical/STEYX.", XLS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    // Check the results of formula cells in the shared formula range.
+    for (SCROW i = 1; i <= 20; ++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-192]
 void ScOpenclTest::testStatisticalFormulaBinomDist()
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 6beed8c..3e2088e 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1455,6 +1455,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocDevSq:
             case ocStDev:
             case ocSlope:
+            case ocSTEYX:
             // Don't change the state.
             break;
             default:
commit 7e96f4aa0b819d9e60221ece2a44eb7dc44b2b7e
Author: shiming zhang <shiming at multicorewareinc.com>
Date:   Tue Nov 12 14:51:36 2013 +0800

    GPU Calc: implemented STEYX
    
    AMLOEXT-187 FIX
    
    Change-Id: Ia7895ec2cbd89ce0f089fd0a35084921e224d8f0
    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 b31dae5..9a718cc 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1369,6 +1369,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 mvSubArguments.push_back(SoPHelper(ts,
                          ft->Children[i], new OpSlope));
                 break;
+            case ocSTEYX:
+                mvSubArguments.push_back(SoPHelper(ts,
+                         ft->Children[i], new OpSTEYX));
+                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 00d44d7..9338164 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -1959,6 +1959,186 @@ void OpSlope::GenSlidingWindowFunction(std::stringstream &ss,
         ss << "}\n";
     }
 }
+void OpSTEYX::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 fSumX=0.0;\n";
+    ss << "    double fSumY=0.0;\n";
+    ss << "    double fMeanX=0.0;\n";
+    ss << "    double fMeanY=0.0;\n";
+    ss << "    double fSumDeltaXDeltaY=0.0;\n";
+    ss << "    double fSumSqrDeltaX=0.0;\n";
+    ss << "    double fSumSqrDeltaY=0.0;\n";
+    ss << "    double fCount=0.0;\n";
+    ss << "    double argX=0.0;\n";
+    ss << "    double argY=0.0;\n";
+    FormulaToken *pCur = vSubArguments[1]->GetFormulaToken();
+    FormulaToken *pCur1 = vSubArguments[0]->GetFormulaToken();
+    assert(pCur);
+    assert(pCur1);
+    if (pCur->GetType() == formula::svDoubleVectorRef&&
+        pCur1->GetType() == formula::svDoubleVectorRef)
+    {
+        const formula::DoubleVectorRefToken* pDVR =
+            dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
+        const formula::DoubleVectorRefToken* pDVR1 =
+            dynamic_cast<const formula::DoubleVectorRefToken *>(pCur1);
+        size_t nCurWindowSize = pDVR->GetRefRowSize();
+        size_t nCurWindowSize1 = pDVR1->GetRefRowSize();
+        if(nCurWindowSize != nCurWindowSize1)
+        {
+            ss << "    return DBL_MAX;\n";
+            ss << "}\n";
+            return ;
+        }
+        ss << "    for (int i = ";
+        if (!pDVR->IsStartFixed() && pDVR->IsEndFixed())
+        {
+#ifdef  ISNAN
+            ss << "gid0; i < " << pDVR->GetArrayLength();
+            ss << " && i < " << nCurWindowSize  << "; i++)\n";
+            ss << "    {\n";
+#else
+            ss << "gid0; i < "<< nCurWindowSize << "; i++)\n";
+            ss << "    {\n";
+#endif
+        }
+        else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+        {
+#ifdef  ISNAN
+            ss << "0; i < " << pDVR->GetArrayLength();
+            ss << " && i < gid0+"<< nCurWindowSize << "; i++)\n";
+            ss << "    {\n";
+#else
+            ss << "0; i < gid0+"<< nCurWindowSize << "; i++)\n";
+            ss << "    {\n";
+#endif
+        }
+        else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+        {
+#ifdef  ISNAN
+            ss << "0; i + gid0 < " << pDVR->GetArrayLength();
+            ss << " &&  i < "<< nCurWindowSize << "; i++)\n";
+            ss << "    {\n";
+#else
+            ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+            ss << "    {\n";
+#endif
+        }
+        else
+        {
+#ifdef  ISNAN
+            ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+            ss << "    {\n";
+#else
+            ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+            ss << "    {\n";
+#endif
+        }
+
+        ss << "        argX = ";
+        ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
+        ss << "        argY = ";
+        ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
+#ifdef  ISNAN
+        ss << "        if (isNan(argX)||isNan(argY))\n";
+        ss << "            continue;\n";
+#endif
+        ss << "        fSumX += argX;\n";
+        ss << "        fSumY += argY;\n";
+        ss << "        fCount += 1;\n";
+        ss << "    }\n";
+
+        ss << "    if (fCount<3.0)\n";
+        ss << "        return DBL_MAX;\n";
+        ss << "    else\n";
+        ss << "    {\n";
+        ss << "        fMeanX=fSumX/fCount;\n";
+        ss << "        fMeanY=fSumY/fCount;\n";
+
+        ss << "        for (int i = ";
+        if (!pDVR->IsStartFixed() && pDVR->IsEndFixed())
+        {
+#ifdef  ISNAN
+            ss << "gid0; i < " << pDVR->GetArrayLength();
+            ss << " && i < " << nCurWindowSize  << "; i++)\n";
+            ss << "        {\n";
+#else
+            ss << "gid0; i < "<< nCurWindowSize << "; i++)\n";
+            ss << "        {\n";
+#endif
+        }
+        else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+        {
+#ifdef  ISNAN
+            ss << "0; i < " << pDVR->GetArrayLength();
+            ss << " && i < gid0+"<< nCurWindowSize << "; i++)\n";
+            ss << "        {\n";
+#else
+            ss << "0; i < gid0+"<< nCurWindowSize << "; i++)\n";
+            ss << "        {\n";
+#endif
+        }
+        else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+        {
+#ifdef  ISNAN
+            ss << "0; i + gid0 < " << pDVR->GetArrayLength();
+            ss << " &&  i < "<< nCurWindowSize << "; i++)\n";
+            ss << "        {\n";
+#else
+            ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+            ss << "        {\n";
+#endif
+        }
+        else
+        {
+#ifdef  ISNAN
+            ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+            ss << "        {\n";
+#else
+            ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+            ss << "        {\n";
+#endif
+        }
+
+        ss << "            argX = ";
+        ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
+        ss << "            argY = ";
+        ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
+#ifdef  ISNAN
+        ss << "            if (isNan(argX)||isNan(argY))\n";
+        ss << "                continue;\n";
+#endif
+        ss << "            fSumDeltaXDeltaY +=(argX-fMeanX)*(argY-fMeanY);\n";
+        ss << "            fSumSqrDeltaX +=(argX-fMeanX)*(argX-fMeanX);\n";
+        ss << "            fSumSqrDeltaY +=(argY-fMeanY)*(argY-fMeanY);\n";
+        ss << "        }\n";
+        ss << "        if(fSumSqrDeltaX==0.0)\n";
+        ss << "            return DBL_MAX;\n";
+        ss << "        else\n";
+        ss << "        {\n";
+        ss << "            return sqrt( (fSumSqrDeltaY - fSumDeltaXDeltaY *";
+        ss << "fSumDeltaXDeltaY / fSumSqrDeltaX) / (fCount-2));\n";
+        ss << "        }\n";
+        ss << "    }\n";
+        ss << "}\n";
+    }
+    else
+    {
+        ss << "    return DBL_MAX;\n";
+        ss << "}\n";
+    }
+}
 void OpFisher::GenSlidingWindowFunction(
     std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments)
 {
diff --git a/sc/source/core/opencl/op_statistical.hxx b/sc/source/core/opencl/op_statistical.hxx
index dc6a7b4..497f782 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -35,6 +35,13 @@ public:
             const std::string sSymName, SubArguments &vSubArguments);
     virtual std::string BinFuncName(void) const { return "Var"; }
 };
+class OpSTEYX: public Normal
+{
+public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+            const std::string sSymName, SubArguments &vSubArguments);
+    virtual std::string BinFuncName(void) const { return "STEYX"; }
+};
 class OpVarP: public Normal
 {
 public:
commit 0d57113267b5cc18632c7ea0e1c1ea4e446a8af2
Author: shiming zhang <shiming at multicorewareinc.com>
Date:   Tue Nov 12 13:36:34 2013 +0800

    GPU Calc: unit test cases for SLOPE
    
    Need to turn on NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-186 BUG
    
    Change-Id: I802de8aa311887ac63fc76fe4e9441678d79e5fb
    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/Slope.xls b/sc/qa/unit/data/xls/opencl/statistical/Slope.xls
new file mode 100644
index 0000000..1ba210e
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/statistical/Slope.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index e5f4e1b..521d69e 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -222,6 +222,7 @@ public:
     void testMathFormulaKombin();
     void testStatisticalFormulaDevSq();
     void testStatisticalFormulaStDev();
+    void testStatisticalFormulaSlope();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -375,6 +376,7 @@ public:
     CPPUNIT_TEST(testMathFormulaKombin);
     CPPUNIT_TEST(testStatisticalFormulaDevSq);
     CPPUNIT_TEST(testStatisticalFormulaStDev);
+    CPPUNIT_TEST(testStatisticalFormulaSlope);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -4213,6 +4215,31 @@ void ScOpenclTest::testStatisticalFormulaStDev()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-186]
+void ScOpenclTest::testStatisticalFormulaSlope()
+{
+    if (!detectOpenCLDevice())
+        return;
+
+    ScDocShellRef xDocSh = loadDoc("opencl/statistical/Slope.", XLS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+
+    ScDocShellRef xDocShRes = loadDoc("opencl/statistical/Slope.", XLS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    // Check the results of formula cells in the shared formula range.
+    for (SCROW i = 1; i <= 20; ++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-192]
 void ScOpenclTest::testStatisticalFormulaBinomDist()
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 4624345..6beed8c 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1454,6 +1454,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocKombin:
             case ocDevSq:
             case ocStDev:
+            case ocSlope:
             // Don't change the state.
             break;
             default:
commit cfbdb1e40030c58f7674cb293b8984d1d129a2cb
Author: shiming zhang <shiming at multicorewareinc.com>
Date:   Tue Nov 12 14:07:00 2013 +0800

    GPU Calc: implemented SLOPE
    
    AMLOEXT-186 FIX
    
    Change-Id: Iff85c08948adf75e6e4d443906b601219155ba80
    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 7171e80..b31dae5 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1365,6 +1365,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 mvSubArguments.push_back(SoPHelper(ts,
                          ft->Children[i], new OpStDev));
                 break;
+            case ocSlope:
+                mvSubArguments.push_back(SoPHelper(ts,
+                         ft->Children[i], new OpSlope));
+                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 3a9b0b5..00d44d7 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -1812,6 +1812,153 @@ void OpStDev::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "        return sqrt(vSum / (fCount - 1.0));\n";
     ss << "}\n";
 }
+void OpSlope::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 fSumX=0.0;\n";
+    ss << "    double fSumY=0.0;\n";
+    ss << "    double fMeanX=0.0;\n";
+    ss << "    double fMeanY=0.0;\n";
+    ss << "    double fSumDeltaXDeltaY=0.0;\n";
+    ss << "    double fSumSqrDeltaX=0.0;\n";
+    ss << "    double fCount=0.0;\n";
+    ss << "    double argX=0.0;\n";
+    ss << "    double argY=0.0;\n";
+    if(vSubArguments.size() != 2)
+    {
+        ss << "    return DBL_MAX;\n";
+        ss << "}\n";
+        return ;
+    }
+    FormulaToken *pCur = vSubArguments[1]->GetFormulaToken();
+    FormulaToken *pCur1 = vSubArguments[0]->GetFormulaToken();
+    assert(pCur);
+    assert(pCur1);
+    if (pCur->GetType() == formula::svDoubleVectorRef&&
+        pCur1->GetType() == formula::svDoubleVectorRef)
+    {
+        const formula::DoubleVectorRefToken* pDVR =
+            dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
+        const formula::DoubleVectorRefToken* pDVR1 =
+            dynamic_cast<const formula::DoubleVectorRefToken *>(pCur1);
+
+        size_t nCurWindowSize = pDVR->GetRefRowSize();
+        size_t nCurWindowSize1 = pDVR1->GetRefRowSize();
+        if(nCurWindowSize != nCurWindowSize1)
+        {
+            ss << "    return DBL_MAX;\n}";
+            ss << "}\n";
+            return ;
+        }
+        ss << "    for (int i = ";
+        if (!pDVR->IsStartFixed() && pDVR->IsEndFixed())
+        {
+#ifdef  ISNAN
+            ss << "gid0; i < " << pDVR->GetArrayLength();
+            ss << " && i < " << nCurWindowSize  << "; i++)\n";
+            ss << "    {\n";
+#else
+            ss << "gid0; i < "<< nCurWindowSize << "; i++)\n";
+            ss << "    {\n";
+#endif
+        }
+        else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+        {
+#ifdef  ISNAN
+            ss << "0; i < " << pDVR->GetArrayLength();
+            ss << " && i < gid0+"<< nCurWindowSize << "; i++)\n";
+            ss << "    {\n";
+#else
+            ss << "0; i < gid0+"<< nCurWindowSize << "; i++)\n";
+            ss << "    {\n";
+#endif
+        }
+        else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+        {
+#ifdef  ISNAN
+            ss << "0; i + gid0 < " << pDVR->GetArrayLength();
+            ss << " &&  i < "<< nCurWindowSize << "; i++)\n";
+            ss << "    {\n";
+#else
+            ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+            ss << "    {\n";
+#endif
+        }
+        else
+        {
+#ifdef  ISNAN
+            ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+            ss << "    {\n";
+#else
+            ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+            ss << "    {\n";
+#endif
+        }
+
+        ss << "        argX = ";
+        ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
+        ss << "        argY = ";
+        ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
+#ifdef  ISNAN
+        ss << "        if (isNan(argX)||isNan(argY))\n";
+        ss << "            continue;\n";
+#endif
+        ss << "        fSumX += argX;\n";
+        ss << "        fSumY += argY;\n";
+        ss << "        fCount += 1;\n";
+        ss << "    }\n";
+
+        ss << "    if (fCount<1.0)\n";
+        ss << "        return DBL_MAX;\n";
+        ss << "    else\n";
+        ss << "    {\n";
+        ss << "        fMeanX=fSumX/fCount;\n";
+        ss << "        fMeanY=fSumY/fCount;\n";
+
+#ifdef  ISNAN
+        ss << "        for (int i = 0; i + gid0 < " << pDVR->GetArrayLength();
+        ss << " && i < " << nCurWindowSize << "; i++)\n";
+        ss << "        {\n";
+#else
+        ss << "        for (int i = 0; i < " << nCurWindowSize << "; i++)\n";
+        ss << "        {\n";
+#endif
+        ss << "            argX = ";
+        ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
+        ss << "            argY = ";
+        ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
+#ifdef  ISNAN
+        ss << "            if (isNan(argX)||isNan(argY))\n";
+        ss << "                 continue;\n";
+#endif
+        ss << "            fSumDeltaXDeltaY +=(argX-fMeanX)*(argY-fMeanY);\n";
+        ss << "            fSumSqrDeltaX +=(argX-fMeanX)*(argX-fMeanX);\n";
+        ss << "        }\n";
+        ss << "        if(fSumSqrDeltaX==0)\n";
+        ss << "            return DBL_MAX;\n";
+        ss << "        else\n";
+        ss << "        {\n";
+        ss << "            return fSumDeltaXDeltaY/fSumSqrDeltaX;\n";
+        ss << "        }\n";
+        ss << "    }\n";
+        ss << "}\n";
+    }
+    else
+    {
+        ss << "    return DBL_MAX;\n";
+        ss << "}\n";
+    }
+}
 void OpFisher::GenSlidingWindowFunction(
     std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments)
 {
diff --git a/sc/source/core/opencl/op_statistical.hxx b/sc/source/core/opencl/op_statistical.hxx
index 48fd7d6..dc6a7b4 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -56,6 +56,13 @@ public:
             const std::string sSymName, SubArguments &vSubArguments);
     virtual std::string BinFuncName(void) const { return "Skewp"; }
 };
+class OpSlope: public Normal
+{
+public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+            const std::string sSymName, SubArguments &vSubArguments);
+    virtual std::string BinFuncName(void) const { return "Slope"; }
+};
 class OpWeibull: public Normal
 {
 public:
commit 5d02ff1e4534f201772c467b60f71903894a431b
Author: shiming zhang <shiming at multicorewareinc.com>
Date:   Tue Nov 12 12:37:00 2013 +0800

    GPU Calc: unit test cases for STDEV
    
    Need to turn on NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-184 BUG
    
    Change-Id: I0b31255ef182c61f53b4670538b7db029ed83cd8
    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/StDev.xls b/sc/qa/unit/data/xls/opencl/statistical/StDev.xls
new file mode 100644
index 0000000..da00293
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/statistical/StDev.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 877dd70..e5f4e1b 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -221,6 +221,7 @@ public:
     void testMathFormulaCeil();
     void testMathFormulaKombin();
     void testStatisticalFormulaDevSq();
+    void testStatisticalFormulaStDev();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -373,6 +374,7 @@ public:
     CPPUNIT_TEST(testMathFormulaCeil);
     CPPUNIT_TEST(testMathFormulaKombin);
     CPPUNIT_TEST(testStatisticalFormulaDevSq);
+    CPPUNIT_TEST(testStatisticalFormulaStDev);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -4186,6 +4188,31 @@ void ScOpenclTest::testStatisticalFormulaVarP()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-184]
+void ScOpenclTest::testStatisticalFormulaStDev()
+{
+    if (!detectOpenCLDevice())
+        return;
+
+    ScDocShellRef xDocSh = loadDoc("opencl/statistical/StDev.", XLS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+
+    ScDocShellRef xDocShRes = loadDoc("opencl/statistical/StDev.", XLS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    // Check the results of formula cells in the shared formula range.
+    for (SCROW i = 1; i <= 20; ++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-192]
 void ScOpenclTest::testStatisticalFormulaBinomDist()
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 6f0245c..4624345 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1453,6 +1453,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocCeil:
             case ocKombin:
             case ocDevSq:
+            case ocStDev:
             // Don't change the state.
             break;
             default:
commit cc666857d603cd4be97489339dea1fc4b9dd3554
Author: shiming zhang <shiming at multicorewareinc.com>
Date:   Tue Nov 12 12:42:44 2013 +0800

    GPU Calc: implemented STDEV
    
    AMLOEXT-184 FIX
    
    Change-Id: I98f620073329cf6670cb53af2b1af01154a16af2
    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 88dce2e..7171e80 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1361,6 +1361,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 mvSubArguments.push_back(SoPHelper(ts,
                          ft->Children[i], new OpDevSq));
                 break;
+            case ocStDev:
+                mvSubArguments.push_back(SoPHelper(ts,
+                         ft->Children[i], new OpStDev));
+                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 56f780f..3a9b0b5 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -1583,6 +1583,235 @@ void OpSkewp::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "    return xcube / fCount;\n";
     ss << "}\n";
 }
+void OpStDev::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 fSum = 0.0;\n";
+    ss << "    double fMean = 0.0;\n";
+    ss << "    double vSum = 0.0;\n";
+    ss << "    double fCount = 0.0;\n";
+    ss << "    double arg = 0.0;\n";
+    unsigned i = vSubArguments.size();
+    while (i--)
+    {
+        FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
+        assert(pCur);
+        if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
+        {
+            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";
+                    ss << "    {\n";
+#else
+                    ss << "gid0; i < "<< nCurWindowSize << "; i++)\n";
+                    ss << "    {\n";
+#endif
+                }
+                else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+                {
+#ifdef  ISNAN
+                    ss << "0; i < " << pDVR->GetArrayLength();
+                    ss << " && i < gid0+"<< nCurWindowSize << "; i++)\n";
+                    ss << "    {\n";
+#else
+                    ss << "0; i < gid0+"<< nCurWindowSize << "; i++)\n";
+                    ss << "    {\n";
+#endif
+                }
+                else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+                {
+#ifdef  ISNAN
+                    ss << "0; i + gid0 < " << pDVR->GetArrayLength();
+                    ss << " &&  i < "<< nCurWindowSize << "; i++)\n";
+                    ss << "    {\n";
+#else
+                    ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+                    ss << "    {\n";
+#endif
+                }
+                else
+                {
+#ifdef  ISNAN
+                    ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+                    ss << "    {\n";
+#else
+                    ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+                    ss << "    {\n";
+#endif
+                }
+
+                ss << "        arg = ";
+                ss << vSubArguments[i]->GenSlidingWindowDeclRef() << ";\n";
+#ifdef  ISNAN
+                ss << "        if (isNan(arg))\n";
+                ss << "            continue;\n";
+#endif
+                ss << "        fSum += arg;\n";
+                ss << "        fCount += 1;\n";
+                ss << "    }\n";
+            }
+            else if (pCur->GetType() == formula::svSingleVectorRef)
+            {
+                const formula::SingleVectorRefToken* pSVR =
+                    dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
+                assert(pSVR);
+#ifdef  ISNAN
+                ss << "    if (gid0 < " << pSVR->GetArrayLength() << ")\n";
+                ss << "    {\n";
+                ss << "        if (!isNan(";
+                ss << vSubArguments[i]->GenSlidingWindowDeclRef() << "))\n";
+                ss << "        {\n";
+#endif
+                ss << "            arg=";
+                ss << vSubArguments[i]->GenSlidingWindowDeclRef() << ";\n";
+                ss << "            fSum += arg;\n";
+                ss << "            fCount += 1;\n";
+#ifdef ISNAN
+                ss << "        }\n";
+                ss << "    }\n";
+#endif
+            }
+            else
+            {
+                ss << "    arg = " << pCur->GetDouble() << ";\n";
+                ss << "    fSum += arg;\n";
+                ss << "    fCount += 1;\n";
+            }
+        }
+        else
+        {
+            ss << "    arg = ";
+            ss << vSubArguments[i]->GenSlidingWindowDeclRef() << ";\n";
+            ss << "    fSum += arg;\n";
+            ss << "    fCount += 1;\n";
+        }
+        if (i == 0)
+        {
+            ss << "    fMean = fSum / " << "fCount" << ";\n";
+        }
+    }
+    i = vSubArguments.size();
+    while (i--)
+    {
+        FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
+        assert(pCur);
+        if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
+        {
+            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";
+                    ss << "    {\n";
+#else
+                    ss << "gid0; i < "<< nCurWindowSize << "; i++)\n";
+                    ss << "    {\n";
+#endif
+                }
+                else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+                {
+#ifdef  ISNAN
+                    ss << "0; i < " << pDVR->GetArrayLength();
+                    ss << " && i < gid0+"<< nCurWindowSize << "; i++)\n";
+                    ss << "    {\n";
+#else
+                    ss << "0; i < gid0+"<< nCurWindowSize << "; i++)\n";
+                    ss << "    {\n";
+#endif
+                }
+                else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+                {
+#ifdef  ISNAN
+                    ss << "0; i + gid0 < " << pDVR->GetArrayLength();
+                    ss << " &&  i < "<< nCurWindowSize << "; i++)\n";
+                    ss << "    {\n";
+#else
+                    ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+                    ss << "    {\n";
+#endif
+                }

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list