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

fengzeng fengzeng at multicorewareinc.com
Thu Nov 14 18:38:02 PST 2013


 sc/qa/unit/data/ods/opencl/math/ArcTan2.ods        |binary
 sc/qa/unit/data/ods/opencl/math/BitLshift.ods      |binary
 sc/qa/unit/data/ods/opencl/math/BitOr.ods          |binary
 sc/qa/unit/data/ods/opencl/math/BitRshift.ods      |binary
 sc/qa/unit/data/ods/opencl/math/BitXor.ods         |binary
 sc/qa/unit/data/xls/opencl/math/averageifs.xls     |binary
 sc/qa/unit/data/xls/opencl/math/combina.xls        |binary
 sc/qa/unit/data/xls/opencl/math/countifs.xls       |binary
 sc/qa/unit/data/xls/opencl/math/even.xls           |binary
 sc/qa/unit/data/xls/opencl/math/log.xls            |binary
 sc/qa/unit/data/xls/opencl/math/mod.xls            |binary
 sc/qa/unit/data/xls/opencl/math/sqrtpi.xls         |binary
 sc/qa/unit/data/xls/opencl/math/sumsq.xls          |binary
 sc/qa/unit/data/xls/opencl/math/trunc.xls          |binary
 sc/qa/unit/data/xls/opencl/statistical/ChiInv.xls  |binary
 sc/qa/unit/data/xls/opencl/statistical/Poisson.xls |binary
 sc/qa/unit/data/xls/opencl/statistical/Skew.xls    |binary
 sc/qa/unit/data/xls/opencl/statistical/Skewp.xls   |binary
 sc/qa/unit/opencl-test.cxx                         |  459 +++++++++
 sc/source/core/opencl/formulagroupcl.cxx           |   74 +
 sc/source/core/opencl/op_math.cxx                  |  799 +++++++++++++++++
 sc/source/core/opencl/op_math.hxx                  |  107 ++
 sc/source/core/opencl/op_statistical.cxx           |  967 ++++++++++++++++++++-
 sc/source/core/opencl/op_statistical.hxx           |   29 
 sc/source/core/opencl/opbase.cxx                   |    3 
 sc/source/core/opencl/opinlinefun_math.hxx         |   16 
 sc/source/core/tool/token.cxx                      |   17 
 27 files changed, 2467 insertions(+), 4 deletions(-)

New commits:
commit d7867b28623e4220f62b8ed9259bed5d8878a3b3
Author: fengzeng <fengzeng at multicorewareinc.com>
Date:   Mon Nov 11 11:37:50 2013 +0800

    GPU Calc: unit test cases for SQRTPI
    
    Need to turn on NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-182 BUG
    
    Change-Id: I314e4b8cc4434d20346c908a7eb2f274838e0d11
    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/sqrtpi.xls b/sc/qa/unit/data/xls/opencl/math/sqrtpi.xls
new file mode 100644
index 0000000..2acf5b2
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/math/sqrtpi.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 648b2bc..b00d1e2 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -215,6 +215,7 @@ public:
     void testStatisticalFormulaPoisson();
     void testMathFormulaSumSQ();
     void testStatisticalFormulaSkewp();
+    void testMathFormulaSqrtPi();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -361,6 +362,7 @@ public:
     CPPUNIT_TEST(testStatisticalFormulaPoisson);
     CPPUNIT_TEST(testMathFormulaSumSQ);
     CPPUNIT_TEST(testStatisticalFormulaSkewp);
+    CPPUNIT_TEST(testMathFormulaSqrtPi);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -4077,6 +4079,28 @@ void ScOpenclTest::testMathFormulaCombina()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-182]
+void ScOpenclTest::testMathFormulaSqrtPi()
+{
+    if (!detectOpenCLDevice())
+            return;
+    ScDocShellRef xDocSh = loadDoc("opencl/math/sqrtpi.", XLS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/math/sqrtpi.", XLS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    for (SCROW i = 0; 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();
+}
 ScOpenclTest::ScOpenclTest()
       : ScBootstrapFixture( "/sc/qa/unit/data" )
 {
commit 6eceefc23748c92d29fb5da8f84fcb54cb78bca4
Author: fengzeng <fengzeng at multicorewareinc.com>
Date:   Mon Nov 11 11:45:02 2013 +0800

    GPU Calc: implemented SQRTPI
    
    AMLOEXT-182 FIX
    
    Change-Id: Iceab026b8945863280d2393f9beb4145dfe45fce
    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 19bff3b..eb74294 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1530,6 +1530,12 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                     mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],
                         new OpAccrint));
                 }
+                else if ( !(pChild->GetExternal().compareTo(OUString(
+                     "com.sun.star.sheet.addin.Analysis.getSqrtpi"))))
+                {
+                    mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],
+                        new OpSqrtPi));
+                }
                 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 0320fe6..78e4249 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1668,6 +1668,58 @@ void OpSumSQ::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "    return sum;\n";
     ss << "}";
 }
+void OpSqrtPi::GenSlidingWindowFunction(std::stringstream &ss,
+            const std::string sSymName, SubArguments &vSubArguments)
+{
+    ss << "\ndouble " << sSymName;
+    ss << "_"<< BinFuncName() <<"(";
+    for (unsigned i = 0; i < vSubArguments.size(); i++)
+    {
+        if (i)
+            ss << ",";
+        vSubArguments[i]->GenSlidingWindowDecl(ss);
+    }
+    ss << ")\n";
+    ss << "{\n";
+    ss << "    int gid0=get_global_id(0);\n";
+    ss << "    double arg0 = 0.0f;\n";
+    FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
+    assert(tmpCur);
+    if(ocPush == vSubArguments[0]->GetFormulaToken()->GetOpCode())
+    {
+        if(tmpCur->GetType() == formula::svSingleVectorRef)
+        {
+            const formula::SingleVectorRefToken*tmpCurDVR=
+                dynamic_cast
+                <const formula::SingleVectorRefToken *>(tmpCur);
+            ss << "    arg0 = ";
+            ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+            ss << ";\n";
+#ifdef ISNAN
+            ss << "    if(isNan(";
+            ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+            ss << ")||(gid0>=";
+            ss << tmpCurDVR->GetArrayLength();
+            ss << "))\n";
+            ss << "    { arg0 = 0.0f; }\n";
+#endif
+        }
+        else if(tmpCur->GetType() == formula::svDouble)
+        {
+            ss << "    arg0=";
+            ss << tmpCur->GetDouble() << ";\n";
+        }
+    }
+    else
+    {
+        ss << "        arg0 = ";
+        ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+        ss << ";\n";
+    }
+    ss << "    return (double)sqrt(arg0 *";
+    ss << " 3.1415926535897932384626433832795f);\n";
+    ss << "}";
+}
 }}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx
index 9475284..f6ead91 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -306,6 +306,14 @@ public:
 
     virtual std::string BinFuncName(void) const { return "Mod"; }
 };
+class OpSqrtPi: public Normal
+{
+public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+            const std::string sSymName, SubArguments &vSubArguments);
+
+    virtual std::string BinFuncName(void) const { return "SqrtPi"; }
+};
 
 class OpCombina: public Normal
 {
commit 384d21b87e69ba8926d40421dc45f61a011fb089
Author: shiming zhang <shiming at multicorewareinc.com>
Date:   Mon Nov 11 10:38:49 2013 +0800

    GPU Calc: unit test cases for SKEWP
    
    Need to turn on NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-81 BUG
    
    Change-Id: I53e181c967b1ce7b2735539f4f714c9a7719cb7a
    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/Skewp.xls b/sc/qa/unit/data/xls/opencl/statistical/Skewp.xls
new file mode 100644
index 0000000..deeca27
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/statistical/Skewp.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 9cf3cbd..648b2bc 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -214,6 +214,7 @@ public:
     void testStatisticalFormulaChiInv();
     void testStatisticalFormulaPoisson();
     void testMathFormulaSumSQ();
+    void testStatisticalFormulaSkewp();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -359,6 +360,7 @@ public:
     CPPUNIT_TEST(testStatisticalFormulaChiInv);
     CPPUNIT_TEST(testStatisticalFormulaPoisson);
     CPPUNIT_TEST(testMathFormulaSumSQ);
+    CPPUNIT_TEST(testStatisticalFormulaSkewp);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1741,6 +1743,31 @@ void ScOpenclTest::testStatisticalFormulaSkew()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-81]
+void ScOpenclTest::testStatisticalFormulaSkewp()
+{
+    if (!detectOpenCLDevice())
+        return;
+
+    ScDocShellRef xDocSh = loadDoc("opencl/statistical/Skewp.", XLS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+
+    ScDocShellRef xDocShRes = loadDoc("opencl/statistical/Skewp.", 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-82]
 void ScOpenclTest::testStatisticalFormulaPearson()
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 14cd987..3d99294 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1446,6 +1446,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocChiInv:
             case ocPoissonDist:
             case ocSumSQ:
+            case ocSkewp:
             // Don't change the state.
             break;
             default:
commit 83db53e58720a4ff01e4400d87707121347df7b0
Author: shiming zhang <shiming at multicorewareinc.com>
Date:   Mon Nov 11 11:02:30 2013 +0800

    GPU Calc: implemented SKEWP
    
    AMLOEXT-81 FIX
    
    Change-Id: I77ea979ca1f046ecc8a865cc7d19cd676fa70cbd
    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 7f21095..19bff3b 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1337,6 +1337,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 mvSubArguments.push_back(SoPHelper(ts,
                          ft->Children[i], new OpSumSQ));
                 break;
+            case ocSkewp:
+                mvSubArguments.push_back(SoPHelper(ts,
+                         ft->Children[i], new OpSkewp));
+                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 9e78511..d02313a 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -1011,6 +1011,345 @@ void OpSkew::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "(fCount - 1.0)) / (fCount - 2.0);\n";
     ss << "}\n";
 }
+void OpSkewp::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 << "    if(fCount <= 2)\n";
+            ss << "        return 0;\n";
+            ss << "    else\n";
+            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
+                }
+                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 << "        vSum += (arg - fMean) * (arg - fMean);\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 << "            vSum += (arg - fMean) * (arg - fMean);\n";
+#ifdef ISNAN
+                ss << "        }\n";
+                ss << "    }\n";
+#endif
+            }
+            else
+            {
+                ss << "    arg = " << pCur->GetDouble() << ";\n";
+                ss << "    vSum += (arg - fMean) * (arg - fMean);\n";
+            }
+        }
+        else
+        {
+            ss << "    arg=";
+            ss << vSubArguments[i]->GenSlidingWindowDeclRef() << ";\n";
+            ss << "    vSum += (arg - fMean) * (arg - fMean);\n";
+        }
+    }
+    ss << "    double fStdDev = sqrt(vSum/fCount);\n";
+    ss << "    double dx = 0.0;\n";
+    ss << "    double xcube = 0.0;\n";
+    ss << "    if(fStdDev == 0.0)\n";
+    ss << "        return DBL_MAX;\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
+                }
+                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 << "        dx = (arg - fMean) / fStdDev;\n";
+                ss << "        xcube = xcube + (dx * dx * dx);\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 << "            dx = (arg - fMean) / fStdDev;\n";
+                ss << "            xcube = xcube+(dx*dx*dx);\n";
+#ifdef ISNAN
+                ss << "        }\n";
+                ss << "    }\n";
+#endif
+            }
+            else
+            {
+                ss << "    arg = " << pCur->GetDouble() << ";\n";
+                ss << "    dx = (arg - fMean) / fStdDev;\n";
+                ss << "    xcube = xcube + (dx * dx * dx);\n";
+            }
+        }
+        else
+        {
+            ss << "    arg = ";
+            ss << vSubArguments[i]->GenSlidingWindowDeclRef() << ";\n";
+            ss << "    dx = (arg - fMean) / fStdDev;\n";
+            ss << "    xcube = xcube + (dx * dx * dx);\n";
+        }
+    }
+    ss << "    return xcube / fCount;\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 5f1681f..e80075e 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 OpSkewp: public Normal
+{
+public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+            const std::string sSymName, SubArguments &vSubArguments);
+    virtual std::string BinFuncName(void) const { return "Skewp"; }
+};
 class OpWeibull: public Normal
 {
 public:
commit 1575b27da2650f30d65dcd93e4c5d5ef9f9ee036
Author: fengzeng <fengzeng at multicorewareinc.com>
Date:   Mon Nov 11 10:25:37 2013 +0800

    GPU Calc: unit test cases for SUMSQ
    
    Need to enable NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-59 BUG
    
    Change-Id: Ia6222c2f3b68c82949c9b4686f9db7ad7cc7bf75
    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/sumsq.xls b/sc/qa/unit/data/xls/opencl/math/sumsq.xls
new file mode 100644
index 0000000..54f00b6
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/math/sumsq.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index c0acc74..9cf3cbd 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -213,6 +213,7 @@ public:
     void testMathFormulaBitXor();
     void testStatisticalFormulaChiInv();
     void testStatisticalFormulaPoisson();
+    void testMathFormulaSumSQ();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -357,6 +358,7 @@ public:
     CPPUNIT_TEST(testMathFormulaBitXor);
     CPPUNIT_TEST(testStatisticalFormulaChiInv);
     CPPUNIT_TEST(testStatisticalFormulaPoisson);
+    CPPUNIT_TEST(testMathFormulaSumSQ);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1371,6 +1373,28 @@ void ScOpenclTest::testMathFormulaSin()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-59]
+void ScOpenclTest::testMathFormulaSumSQ()
+{
+    if (!detectOpenCLDevice())
+            return;
+    ScDocShellRef xDocSh = loadDoc("opencl/math/sumsq.", XLS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/math/sumsq.", XLS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    for (SCROW i = 0; i < 20; ++i)
+    {
+        double fLibre = pDoc->GetValue(ScAddress(5,i,0));
+        double fExcel = pDocRes->GetValue(ScAddress(5,i,0));
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+    }
+    xDocSh->DoClose();
+    xDocShRes->DoClose();
+}
 //[AMLOEXT-60]
 void ScOpenclTest::testMathFormulaTan()
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 6b4fadb..14cd987 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1445,6 +1445,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocBitXor:
             case ocChiInv:
             case ocPoissonDist:
+            case ocSumSQ:
             // Don't change the state.
             break;
             default:
commit 06a38321d5e139e007a0b7f5a0fd82a3eae84ec9
Author: fengzeng <fengzeng at multicorewareinc.com>
Date:   Mon Nov 11 10:32:06 2013 +0800

    GPU Calc: implemented SUMSQ
    
    AMLOEXT-59 FIX
    
    Change-Id: I33c8241febef766db4ff46e5ed875b46d5e1275c
    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 967a0df..7f21095 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1333,6 +1333,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 mvSubArguments.push_back(SoPHelper(ts,
                          ft->Children[i],new OpPoisson));
                 break;
+            case ocSumSQ:
+                mvSubArguments.push_back(SoPHelper(ts,
+                         ft->Children[i], new OpSumSQ));
+                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 b809081..0320fe6 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1554,6 +1554,120 @@ void OpBitRshift::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "num * pow(2.0, fabs(shift_amount)));\n";
     ss << "}";
 }
+void OpSumSQ::GenSlidingWindowFunction(std::stringstream &ss,
+            const std::string sSymName, SubArguments &vSubArguments)
+{
+    ss << "\ndouble " << sSymName;
+    ss << "_"<< BinFuncName() <<"(";
+    for (unsigned i = 0; i < vSubArguments.size(); ++i)
+    {
+        if (i)
+            ss << ",";
+        vSubArguments[i]->GenSlidingWindowDecl(ss);
+    }
+    ss << ")\n";
+    ss << "{\n";
+    ss << "    int gid0=get_global_id(0);\n";
+    ss << "    double sum = 0.0f, arg;\n";
+    for( unsigned i=0; i < vSubArguments.size(); ++i)
+    {
+        FormulaToken *tmpCur = vSubArguments[i]->GetFormulaToken();
+        assert(tmpCur);
+        if(ocPush == vSubArguments[i]->GetFormulaToken()->GetOpCode())
+        {
+            if (tmpCur->GetType() == formula::svDoubleVectorRef)
+            {
+                const formula::DoubleVectorRefToken* pDVR =
+            dynamic_cast<const formula::DoubleVectorRefToken *>(tmpCur);
+                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();
+                ss << ";\n";
+#ifdef  ISNAN
+                ss << "        if (isNan(arg))\n";
+                ss << "            continue;\n";
+#endif
+                ss << "        sum += arg*arg;\n";
+                ss << "    }\n";
+            }
+            else if(tmpCur->GetType() == formula::svSingleVectorRef)
+            {
+                const formula::SingleVectorRefToken* tmpCurDVR=
+                      dynamic_cast<
+                      const formula::SingleVectorRefToken *>(tmpCur);
+                ss << "    arg = ";
+                ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+                ss << ";\n";
+#ifdef ISNAN
+                ss << "    if(isNan(arg)||(gid0>=";
+                ss << tmpCurDVR->GetArrayLength();
+                ss << "))\n";
+                ss << "        arg = 0.0f;\n";
+                ss << "    sum += arg * arg;\n";
+#endif
+            }
+            else if(tmpCur->GetType() == formula::svDouble)
+            {
+                ss << "        arg = ";
+                ss << tmpCur->GetDouble() << ";\n";
+                ss << "        sum += arg*arg;\n";
+            }
+        }
+        else
+        {
+            ss << "        arg = ";
+            ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss << ";\n";
+            ss << "        sum += arg*arg;\n";
+        }
+    }
+    ss << "    return sum;\n";
+    ss << "}";
+}
 }}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx
index b6d2432..9475284 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -218,6 +218,14 @@ public:
 
     virtual std::string BinFuncName(void) const { return "Cot"; }
 };
+class OpSumSQ: public Normal
+{
+public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+            const std::string sSymName, SubArguments &vSubArguments);
+
+    virtual std::string BinFuncName(void) const { return "SumSQ"; }
+};
 class OpCoth: public Normal
 {
 public:
commit 31dbc51ebd1ef6651a9ce71e2214ac6d954af69b
Author: hongyu zhong <hongyu at multicorewareinc.com>
Date:   Sun Nov 10 11:00:18 2013 +0800

    GPU Calc: unit test cases for POISSON
    
    Need to turn on NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-150 BUG
    
    Change-Id: I29324659b31d98905ead88d0d0cf44361ad1df16
    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/Poisson.xls b/sc/qa/unit/data/xls/opencl/statistical/Poisson.xls
new file mode 100644
index 0000000..135c5fe
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/statistical/Poisson.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 7304764..c0acc74 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -212,6 +212,7 @@ public:
     void testMathFormulaBitRshift();
     void testMathFormulaBitXor();
     void testStatisticalFormulaChiInv();
+    void testStatisticalFormulaPoisson();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -355,6 +356,7 @@ public:
     CPPUNIT_TEST(testMathFormulaBitRshift);
     CPPUNIT_TEST(testMathFormulaBitXor);
     CPPUNIT_TEST(testStatisticalFormulaChiInv);
+    CPPUNIT_TEST(testStatisticalFormulaPoisson);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -3404,6 +3406,29 @@ void ScOpenclTest::testMathFormulaBitAnd()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-150]
+void ScOpenclTest::testStatisticalFormulaPoisson()
+{
+    if (!detectOpenCLDevice())
+        return;
+    ScDocShellRef xDocSh = loadDoc("opencl/statistical/Poisson.", XLS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/statistical/Poisson.", XLS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    // Check the results of formula cells in the shared formula range.
+    for (SCROW i = 1; i <= 19; ++i)
+    {
+        double fLibre = pDoc->GetValue(ScAddress(3,i,0));
+        double fExcel = pDocRes->GetValue(ScAddress(3,i,0));
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+    }
+    xDocSh->DoClose();
+    xDocShRes->DoClose();
+}
 //[AMLOEXT-151]
 void ScOpenclTest::testStatisticalFormulaExpondist()
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index cd2018b..6b4fadb 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1444,6 +1444,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocBitRshift:
             case ocBitXor:
             case ocChiInv:
+            case ocPoissonDist:
             // Don't change the state.
             break;
             default:
commit 40d760db64c8def4766a0da1102c55ef6ab67cf8
Author: hongyu zhong <hongyu at multicorewareinc.com>
Date:   Sun Nov 10 11:06:36 2013 +0800

    GPU Calc: implemented POISSON
    
    AMLOEXT-150 FIX
    
    Change-Id: I2ea5128b4b116a91477c1a339a65d3a052f4ebca
    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 59cae60..967a0df 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1329,6 +1329,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 mvSubArguments.push_back(SoPHelper(ts,
                          ft->Children[i],new OpChiInv));
                 break;
+            case ocPoissonDist:
+                mvSubArguments.push_back(SoPHelper(ts,
+                         ft->Children[i],new OpPoisson));
+                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 4144cd6..9e78511 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -4305,7 +4305,154 @@ void OpBetaDist::BinInlineFun(std::set<std::string>& decls,
     funs.insert(lcl_GetBetaHelperContFrac);funs.insert(GetLogBeta);
     funs.insert(GetBeta);funs.insert(lcl_getLanczosSum);
 }
-
+void OpPoisson::BinInlineFun(std::set<std::string>& decls,
+    std::set<std::string>& funs)
+{
+    decls.insert(fHalfMachEpsDecl);
+    funs.insert("");
+    decls.insert(fMaxGammaArgumentDecl);
+    funs.insert("");
+    decls.insert(fBigInvDecl);
+    funs.insert("");
+    decls.insert(GetLogGammaDecl);
+    funs.insert(GetLogGamma);
+    decls.insert(lcl_GetLogGammaHelperDecl);
+    funs.insert(lcl_GetLogGammaHelper);
+    decls.insert(lcl_GetGammaHelperDecl);
+    funs.insert(lcl_GetGammaHelper);
+    decls.insert(lcl_getLanczosSumDecl);
+    funs.insert(lcl_getLanczosSum);
+    decls.insert(GetUpRegIGammaDecl);
+    funs.insert(GetUpRegIGamma);
+    decls.insert(GetGammaContFractionDecl);
+    funs.insert(GetGammaContFraction);
+    decls.insert(GetGammaSeriesDecl);
+    funs.insert(GetGammaSeries);
+}
+void OpPoisson::GenSlidingWindowFunction(
+    std::stringstream &ss,const std::string sSymName,
+    SubArguments &vSubArguments)
+{
+    ss << "\ndouble " << sSymName;
+    ss << "_"<< BinFuncName() <<"(";
+    for (unsigned i = 0; i < vSubArguments.size(); i++)
+    {
+        if (i)
+            ss << ",";
+        vSubArguments[i]->GenSlidingWindowDecl(ss);
+    }
+    ss << ")\n";
+    ss << "{\n";
+    ss << "    double x,lambda,tmp;\n";
+    ss << "    int bCumulative;\n";
+    ss << "    int gid0=get_global_id(0);\n";
+#ifdef ISNAN
+    FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken();
+    const formula::SingleVectorRefToken*tmpCurDVR0= dynamic_cast<const
+    formula::SingleVectorRefToken *>(tmpCur0);
+    FormulaToken *tmpCur1 = vSubArguments[1]->GetFormulaToken();
+    const formula::SingleVectorRefToken*tmpCurDVR1= dynamic_cast<const
+    formula::SingleVectorRefToken *>(tmpCur1);
+    FormulaToken *tmpCur2 = vSubArguments[2]->GetFormulaToken();
+    const formula::SingleVectorRefToken*tmpCurDVR2= dynamic_cast<const
+    formula::SingleVectorRefToken *>(tmpCur2);
+    ss << "    int buffer_x_len = ";
+    ss << tmpCurDVR0->GetArrayLength();
+    ss << ";\n";
+    ss << "     int buffer_lambda_len = ";
+    ss << tmpCurDVR1->GetArrayLength();
+    ss << ";\n";
+    ss << "    int buffer_bCumulative_len = ";
+    ss << tmpCurDVR2->GetArrayLength();
+    ss << ";\n";
+#endif
+#ifdef ISNAN
+    ss <<"    if((gid0)>=buffer_x_len || isNan(";
+    ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+    ss <<"))\n";
+    ss <<"        x = 0;\n";
+    ss <<"    else \n";
+#endif
+    ss <<"         x ="<<vSubArguments[0]->GenSlidingWindowDeclRef();
+    ss << ";\n";
+#ifdef ISNAN
+    ss <<"    if((gid0)>=buffer_lambda_len || isNan(";
+    ss << vSubArguments[1]->GenSlidingWindowDeclRef();
+    ss <<"))\n";
+    ss <<"        lambda = 0;\n";
+    ss <<"    else \n";
+#endif
+    ss <<"        lambda ="<<vSubArguments[1]->GenSlidingWindowDeclRef();
+    ss << ";\n";
+#ifdef ISNAN
+    ss <<"    if((gid0)>=buffer_bCumulative_len || isNan(";
+    ss << vSubArguments[2]->GenSlidingWindowDeclRef();
+    ss <<"))\n";
+    ss <<"    bCumulative = 0;\n";
+    ss <<"else \n";
+#endif
+    ss <<"     bCumulative ="<<vSubArguments[2]->GenSlidingWindowDeclRef();
+    ss << ";\n";
+    ss << "    if (!bCumulative)\n";
+    ss << "    {\n";
+    ss << "        if(lambda == 0.0)\n";
+    ss << "        {\n";
+    ss << "            return 0;\n";
+    ss << "        }\n";
+    ss << "        else\n";
+    ss << "        {\n";
+    ss << "            if (lambda >712)\n";
+    ss << "            {\n";
+    ss << "            tmp = (exp(x*log(lambda)-lambda-GetLogGamma(x+1.0)));\n";
+    ss << "            return tmp;\n";
+    ss << "            }\n";
+    ss << "            else\n";
+    ss << "            {\n";
+    ss << "                double fPoissonVar = 1.0;\n";
+    ss << "                for ( int f = 0; f < x; ++f )\n";
+    ss << "                    fPoissonVar *= lambda / ( (double)f + 1.0 );\n";
+    ss << "                tmp = ( fPoissonVar * exp( -lambda ) );\n";
+    ss << "                return tmp;\n";
+    ss << "            }\n";
+    ss << "        }\n";
+    ss << "     } \n";
+    ss << "     else\n";
+    ss << "     {\n";
+    ss << "         if (lambda == 0.0)\n";
+    ss << "         {\n";
+    ss << "             return 1;\n";
+    ss << "         }\n";
+    ss << "         else\n";
+    ss << "         {\n";
+    ss << "             if (lambda > 712 )\n";
+    ss << "             {\n";
+    ss << "                 tmp = (GetUpRegIGamma(x+1.0,lambda));\n";
+    ss << "                 return tmp;\n";
+    ss << "             }\n";
+    ss << "             else\n";
+    ss << "             {\n";
+    ss << "                 if (x >= 936.0)\n";
+    ss << "                 {\n";
+    ss << "                     return 1;\n";
+    ss << "                 }\n";
+    ss << "                 else\n";
+    ss << "                 {\n";
+    ss << "                     double fSummand = exp(-lambda);\n";
+    ss << "                     double fSum = fSummand;\n";
+    ss << "                     int nEnd = (int) (x + 0.5);\n";
+    ss << "                     for (int i = 1; i <= nEnd; i++)\n";
+    ss << "                     {\n";
+    ss << "                         fSummand = (fSummand*lambda)/(double)i;\n";
+    ss << "                         fSum += fSummand;\n";
+    ss << "                     }\n";
+    ss << "                     tmp = fSum;\n";
+    ss << "                     return tmp;\n";
+    ss << "                 }\n";
+    ss << "             }\n";
+    ss << "         }\n";
+    ss << "     }\n";
+    ss << "}\n";
+}
 void OpBetaDist::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 ed88bf2..5f1681f 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -291,6 +291,14 @@ class OpChiInv:public Normal{
     virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>&);
     virtual std::string BinFuncName(void) const { return "OpChiInv"; }
 };
+class OpPoisson:public Normal{
+    public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+            const std::string sSymName, SubArguments &vSubArguments);
+    virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>&);
+    virtual std::string BinFuncName(void) const { return "OpPoisson"; }
+};
+
 class OpGammaInv: public Normal
 {
 public:
commit c7d6acd37ba8ca91deb2f8de55cf44e370bc8f08
Author: hongyu zhong <hongyu at multicorewareinc.com>
Date:   Sun Nov 10 10:32:15 2013 +0800

    GPU Calc: unit test cases for CHIINV
    
    Need to enable NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-173 BUG
    
    Change-Id: I630f4f7c994dacc601421e96290db5e2408ca569
    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/ChiInv.xls b/sc/qa/unit/data/xls/opencl/statistical/ChiInv.xls
new file mode 100644
index 0000000..9de54c1
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/statistical/ChiInv.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index ca5913c..7304764 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -211,6 +211,7 @@ public:
     void testMathFormulaBitLshift();
     void testMathFormulaBitRshift();
     void testMathFormulaBitXor();
+    void testStatisticalFormulaChiInv();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -353,6 +354,7 @@ public:
     CPPUNIT_TEST(testMathFormulaBitLshift);
     CPPUNIT_TEST(testMathFormulaBitRshift);
     CPPUNIT_TEST(testMathFormulaBitXor);
+    CPPUNIT_TEST(testStatisticalFormulaChiInv);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -3862,6 +3864,29 @@ void ScOpenclTest::testMathFormulaLog()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-173]
+void ScOpenclTest::testStatisticalFormulaChiInv()
+{
+    if (!detectOpenCLDevice())
+        return;
+    ScDocShellRef xDocSh = loadDoc("opencl/statistical/ChiInv.", XLS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/statistical/ChiInv.", XLS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    // Check the results of formula cells in the shared formula range.
+    for (SCROW i = 1; i <= 10; ++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-176 ]
 void ScOpenclTest::testMathCountIfsFormula()
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 21b5bcc..cd2018b 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1443,6 +1443,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocBitLshift:
             case ocBitRshift:
             case ocBitXor:
+            case ocChiInv:
             // Don't change the state.
             break;
             default:
commit 06571f68c74b54fe2c2acbf6ae87ceaa2a8b2d8b
Author: hongyu zhong <hongyu at multicorewareinc.com>
Date:   Sun Nov 10 10:44:13 2013 +0800

    GPU Calc: implemented CHIINV
    
    AMLOEXT-173 FIX
    
    Change-Id: I04f09bf111f9dff50353beb4e4d094365574f8ba
    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 d8f4b8a..59cae60 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1325,6 +1325,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 mvSubArguments.push_back(SoPHelper(ts,
                     ft->Children[i], new OpBitXor));
                 break;
+            case ocChiInv:
+                mvSubArguments.push_back(SoPHelper(ts,
+                         ft->Children[i],new OpChiInv));
+                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 636afd0..4144cd6 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -1873,6 +1873,146 @@ void OpRsq::GenSlidingWindowFunction(
     ss << "return (tmp * tmp);\n";
     ss << "}\n";
 }
+
+void OpChiInv::BinInlineFun(std::set<std::string>& decls,
+    std::set<std::string>& funs)
+{
+    decls.insert(fMachEpsDecl);
+    funs.insert("");
+    decls.insert(fBigInvDecl);
+    funs.insert("");
+    decls.insert(fHalfMachEpsDecl);
+    funs.insert("");
+    decls.insert(lcl_IterateInverseChiInvDecl);
+    funs.insert(lcl_IterateInverseChiInv);
+    decls.insert(GetChiDistDecl);
+    funs.insert(GetChiDist);
+    decls.insert(lcl_HasChangeOfSignDecl);
+    funs.insert(lcl_HasChangeOfSign);
+    decls.insert(GetUpRegIGammaDecl);
+    funs.insert(GetUpRegIGamma);
+    decls.insert(GetGammaContFractionDecl);
+    funs.insert(GetGammaContFraction);
+    decls.insert(GetGammaSeriesDecl);
+    funs.insert(GetGammaSeries);
+}
+void OpChiInv::GenSlidingWindowFunction(
+    std::stringstream &ss,const std::string sSymName,
+    SubArguments &vSubArguments)
+{
+    ss << "\ndouble " << sSymName;
+    ss << "_"<< BinFuncName() <<"(";
+    for (unsigned i = 0; i < vSubArguments.size(); i++)
+    {
+        if (i)
+            ss << ",";
+        vSubArguments[i]->GenSlidingWindowDecl(ss);
+    }
+    ss << ")\n";
+    ss << "{\n";
+    ss << "    double tmp0,tmp1,tmp;\n";
+    ss << "    int gid0=get_global_id(0);\n";
+    size_t i = vSubArguments.size();
+    size_t nItems = 0;
+    ss <<"\n    ";
+    for (i = 0; i < vSubArguments.size(); i++)
+    {
+        FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
+        assert(pCur);
+        if (pCur->GetType() == formula::svDoubleVectorRef)
+        {
+            const formula::DoubleVectorRefToken* pDVR =
+            dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
+            size_t nCurWindowSize = pDVR->GetRefRowSize();
+            ss << "for (int i = ";
+            if (!pDVR->IsStartFixed() && pDVR->IsEndFixed()) {
+#ifdef  ISNAN
+                ss << "gid0; i < " << pDVR->GetArrayLength();
+                ss << " && i < " << nCurWindowSize  << "; i++){\n";
+#else
+                ss << "gid0; i < "<< nCurWindowSize << "; i++)\n";
+#endif
+                } else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed()) {
+#ifdef  ISNAN
+                ss << "0; i < " << pDVR->GetArrayLength();
+                ss << " && i < gid0+"<< nCurWindowSize << "; i++){\n";
+#else
+                ss << "0; i < gid0+"<< nCurWindowSize << "; i++)\n";
+#endif
+                } else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed()){
+#ifdef  ISNAN
+                ss << "0; i + gid0 < " << pDVR->GetArrayLength();
+                ss << " &&  i < "<< nCurWindowSize << "; i++){\n";
+#else
+                ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+#endif
+                }
+                else {
+#ifdef  ISNAN
+                ss << "0; i < "<< nCurWindowSize << "; i++){\n";
+#else
+                ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+#endif
+                }
+                nItems += nCurWindowSize;
+            }
+            else if (pCur->GetType() == formula::svSingleVectorRef)
+            {
+#ifdef  ISNAN
+                    const formula::SingleVectorRefToken* pSVR =
+                    dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
+                ss << "if (gid0 < " << pSVR->GetArrayLength() << "){\n";
+#else
+                nItems += 1;
+#endif
+            }
+            else if (pCur->GetType() == formula::svDouble)
+            {
+#ifdef  ISNAN
+                ss << "{\n";
+#endif
+                nItems += 1;
+            }
+            else
+            {
+#ifdef  ISNAN
+#endif
+                nItems += 1;
+            }
+#ifdef  ISNAN
+            if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
+            {
+                ss << "if (isNan(";
+                ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+                ss << "))\n";
+                ss << "    tmp"<<i<<"= 0;\n";
+                ss << "else\n";
+                ss <<"tmp"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
+                ss << ";\n}\n";
+            }
+            else
+            {
+               ss << "tmp"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
+               ss << ";\n";
+            }
+#else
+    ss << "tmp"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
+    ss << ";\n";
+#endif
+            }
+    ss << "    tmp1 = floor(tmp1);";
+    ss << "    if (tmp1 < 1.0 || tmp0 <= 0.0 || tmp0 > 1.0 )\n";
+    ss << "    {\n";
+    ss << "        return DBL_MIN;\n";
+    ss << "    }\n";
+    ss << "    bool bConvError;\n";
+    ss << "    double fVal = lcl_IterateInverseChiInv";
+    ss << "(tmp0, tmp1, tmp1*0.5, tmp1, &bConvError);\n";
+    ss << "    if(bConvError)\n";
+    ss << "        return DBL_MIN;\n";
+    ss << "    return fVal;\n";
+    ss << "}\n";
+}
 void OpNormdist::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 e9ab0e6..ed88bf2 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -284,6 +284,13 @@ public:
     virtual std::string BinFuncName(void) const { return "ChiSqInv"; }
     virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>& );
 };
+class OpChiInv:public Normal{
+    public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+            const std::string sSymName, SubArguments &vSubArguments);
+    virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>&);
+    virtual std::string BinFuncName(void) const { return "OpChiInv"; }
+};
 class OpGammaInv: public Normal
 {
 public:
commit ea652ae629103d4826c662cd0b0830617a3dac33
Author: yangzhang <yangzhang at multicorewareinc.com>
Date:   Sun Nov 10 10:18:22 2013 +0800

    GPU Calc: unit test cases for BITXOR
    
    Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-178 BUG
    
    Change-Id: Iab8988244328ab9be2ccf0d69ee862c82cf05738
    Signed-off-by: haochen <haochen at multicorewareinc.com>
    Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>

diff --git a/sc/qa/unit/data/ods/opencl/math/BitXor.ods b/sc/qa/unit/data/ods/opencl/math/BitXor.ods
new file mode 100644
index 0000000..c8e812a
Binary files /dev/null and b/sc/qa/unit/data/ods/opencl/math/BitXor.ods differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 763a80c..ca5913c 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -210,6 +210,7 @@ public:
     void testMathFormulaBitOr();
     void testMathFormulaBitLshift();
     void testMathFormulaBitRshift();
+    void testMathFormulaBitXor();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -351,6 +352,7 @@ public:
     CPPUNIT_TEST(testMathFormulaBitOr);
     CPPUNIT_TEST(testMathFormulaBitLshift);
     CPPUNIT_TEST(testMathFormulaBitRshift);
+    CPPUNIT_TEST(testMathFormulaBitXor);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -3883,6 +3885,29 @@ void ScOpenclTest::testMathCountIfsFormula()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-178]
+void ScOpenclTest::testMathFormulaBitXor()
+{
+    if (!detectOpenCLDevice())
+        return;
+    ScDocShellRef xDocSh = loadDoc("opencl/math/BitXor.", ODS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/math/BitXor.", ODS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    // Verify BitXor Function
+    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-179]
 void ScOpenclTest::testMathAverageIfsFormula()
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index f0d2d7c..21b5bcc 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1442,6 +1442,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocBitOr:
             case ocBitLshift:
             case ocBitRshift:
+            case ocBitXor:
             // Don't change the state.
             break;
             default:
commit a5349f2a504e1349a807456ecf16bc182c396143
Author: yangzhang <yangzhang at multicorewareinc.com>
Date:   Sun Nov 10 10:22:51 2013 +0800

    GPU Calc: implemented for BITXOR
    
    AMLOEXT-178 FIX
    
    Change-Id: I7815b6455270cd85e8de95f2afc52fa7029ca478
    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 729e5e9..d8f4b8a 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1321,6 +1321,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 mvSubArguments.push_back(SoPHelper(ts,
                     ft->Children[i], new OpBitRshift));
                 break;
+            case ocBitXor:
+                mvSubArguments.push_back(SoPHelper(ts,
+                    ft->Children[i], new OpBitXor));
+                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 6f34d61..b809081 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1422,6 +1422,48 @@ void OpBitOr::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "    return (long)num1 | (long)num2;\n";
     ss << "}";
 }
+void OpBitXor::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 num1 = " << GetBottom() << ";\n";
+    ss << "    double num2 = " << GetBottom() << ";\n";
+#ifdef ISNAN
+    FormulaToken *iNum1 = vSubArguments[0]->GetFormulaToken();
+    const formula::SingleVectorRefToken* tmpCurDVRNum1=
+        dynamic_cast<const formula::SingleVectorRefToken *>(iNum1);
+    FormulaToken *iNum2 = vSubArguments[1]->GetFormulaToken();
+    const formula::SingleVectorRefToken* tmpCurDVRNum2=
+        dynamic_cast<const formula::SingleVectorRefToken *>(iNum2);
+    ss << "    int buffer_num1_len = " << tmpCurDVRNum1->GetArrayLength() << ";\n";
+    ss << "    int buffer_num2_len = " << tmpCurDVRNum2->GetArrayLength() << ";\n";
+
+    ss << "    if((gid0)>=buffer_num1_len || isNan(";
+    ss << vSubArguments[0]->GenSlidingWindowDeclRef() << "))\n";
+    ss << "        num1 = " << GetBottom() << ";\n";
+    ss << "    else\n    ";
+#endif
+    ss << "    num1 = floor(" << vSubArguments[0]->GenSlidingWindowDeclRef();
+    ss << ");\n";
+#ifdef ISNAN
+    ss << "    if((gid0)>=buffer_num2_len || isNan(";
+    ss << vSubArguments[1]->GenSlidingWindowDeclRef() << "))\n";
+    ss << "        num2 = " << GetBottom() << ";\n";
+    ss << "    else\n    ";
+#endif
+    ss << "    num2 = floor(" << vSubArguments[1]->GenSlidingWindowDeclRef();
+    ss << ");\n";
+    ss << "    return (long)num1 ^ (long)num2;\n";
+    ss << "}";
+}
 void OpBitLshift::GenSlidingWindowFunction(std::stringstream &ss,
     const std::string sSymName, SubArguments &vSubArguments)
 {
diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx
index c794e4a..b6d2432 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -175,6 +175,13 @@ public:
     virtual std::string GetBottom(void) { return "0.0"; }
     virtual std::string BinFuncName(void) const { return "ScBitOr"; }
 };
+class OpBitXor:public Normal{
+public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+        const std::string sSymName, SubArguments &vSubArguments);
+    virtual std::string GetBottom(void) { return "0.0"; }
+    virtual std::string BinFuncName(void) const { return "ScBitXor"; }
+};
 class OpBitLshift:public Normal{
 public:
     virtual void GenSlidingWindowFunction(std::stringstream &ss,
commit 8d47d9837d2c2841d6bd941f01571b75e89d3224
Author: yangzhang <yangzhang at multicorewareinc.com>
Date:   Sun Nov 10 10:07:46 2013 +0800

    GPU Calc: unit test cases for BITRSHFIT
    
    Need to enable NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-168 BUG
    
    Change-Id: Id7c8b783b44915b4410bba500e520ff48b9f3a1f
    Signed-off-by: haochen <haochen at multicorewareinc.com>
    Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>

diff --git a/sc/qa/unit/data/ods/opencl/math/BitRshift.ods b/sc/qa/unit/data/ods/opencl/math/BitRshift.ods
new file mode 100644
index 0000000..f1039df
Binary files /dev/null and b/sc/qa/unit/data/ods/opencl/math/BitRshift.ods differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index ff65065..763a80c 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -209,6 +209,7 @@ public:
     void testMathFormulaArcTan2();
     void testMathFormulaBitOr();
     void testMathFormulaBitLshift();
+    void testMathFormulaBitRshift();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -349,6 +350,7 @@ public:
     CPPUNIT_TEST(testMathFormulaArcTan2);
     CPPUNIT_TEST(testMathFormulaBitOr);
     CPPUNIT_TEST(testMathFormulaBitLshift);
+    CPPUNIT_TEST(testMathFormulaBitRshift);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -3790,6 +3792,29 @@ void ScOpenclTest::testMathFormulaBitLshift()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-168]
+void ScOpenclTest::testMathFormulaBitRshift()
+{
+    if (!detectOpenCLDevice())
+        return;
+    ScDocShellRef xDocSh = loadDoc("opencl/math/BitRshift.", ODS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/math/BitRshift.", ODS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    // Verify BitRshift Function
+    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-169]
 void ScOpenclTest::testMathFormulaFloor()
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index c1c9e89..f0d2d7c 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1441,6 +1441,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocArcTan2:
             case ocBitOr:
             case ocBitLshift:
+            case ocBitRshift:
             // Don't change the state.
             break;
             default:
commit a9d49e21bf0d8ca9d516a2897067ad2185576f5d
Author: yangzhang <yangzhang at multicorewareinc.com>
Date:   Sun Nov 10 10:11:40 2013 +0800

    GPU Calc: implemented BITRSHFIT
    
    AMLOEXT-168 FIX
    
    Change-Id: I5596ea32861eeb7eb36d9800d410ebada0721745
    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 a761cc3..729e5e9 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1317,6 +1317,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 mvSubArguments.push_back(SoPHelper(ts,
                     ft->Children[i], new OpBitLshift));
                 break;
+            case ocBitRshift:
+                mvSubArguments.push_back(SoPHelper(ts,
+                    ft->Children[i], new OpBitRshift));
+                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 c6e1f7e..6f34d61 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1466,7 +1466,52 @@ void OpBitLshift::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "num / pow(2.0, fabs(shift_amount)));\n";
     ss << "}";
 }
+void OpBitRshift::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 num = " << GetBottom() << ";\n";
+    ss << "    double shift_amount = " << GetBottom() << ";\n";
+#ifdef ISNAN
+    FormulaToken *iNum = vSubArguments[0]->GetFormulaToken();
+    const formula::SingleVectorRefToken* tmpCurDVRNum=
+        dynamic_cast<const formula::SingleVectorRefToken*>(iNum);
+    FormulaToken *iShiftAmount = vSubArguments[1]->GetFormulaToken();
+    const formula::SingleVectorRefToken* tmpCurDVRShiftAmount=
+        dynamic_cast<const formula::SingleVectorRefToken*>(iShiftAmount);
+    ss << "    int buffer_num_len = ";
+    ss << tmpCurDVRNum->GetArrayLength() << ";\n";
+    ss << "    int buffer_shift_amount_len = ";
+    ss << tmpCurDVRShiftAmount->GetArrayLength() << ";\n";
 
+    ss << "    if((gid0)>=buffer_num_len || isNan(";
+    ss << vSubArguments[0]->GenSlidingWindowDeclRef() << "))\n";
+    ss << "        num = " << GetBottom() << ";\n";
+    ss << "    else\n    ";
+#endif
+    ss << "    num = floor(";
+    ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ");\n";
+#ifdef ISNAN
+    ss << "    if((gid0)>=buffer_shift_amount_len || isNan(";
+    ss << vSubArguments[1]->GenSlidingWindowDeclRef() << "))\n";
+    ss << "        shift_amount = " <<GetBottom()<< ";\n";
+    ss << "    else\n    ";
+#endif
+    ss << "    shift_amount = floor(";
+    ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ");\n";
+    ss << "    return floor(";
+    ss << "shift_amount >= 0 ? num / pow(2.0, shift_amount) : ";
+    ss << "num * pow(2.0, fabs(shift_amount)));\n";
+    ss << "}";
+}
 }}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx
index 33cc6a2..c794e4a 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -182,6 +182,13 @@ public:
     virtual std::string GetBottom(void) { return "0.0"; }
     virtual std::string BinFuncName(void) const { return "ScBitLshift"; }
 };
+class OpBitRshift:public Normal{
+public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+        const std::string sSymName, SubArguments &vSubArguments);
+    virtual std::string GetBottom(void) { return "0.0"; }
+    virtual std::string BinFuncName(void) const { return "ScBitRshift"; }
+};
 class OpLn: public CheckVariables
 {
 public:
commit 0f08b857c9dd01809286f78375d6195f8da85323
Author: yangzhang <yangzhang at multicorewareinc.com>
Date:   Sun Nov 10 09:52:22 2013 +0800

    GPU Calc: unit test cases for BITLSHFIT
    
    Need to turn on NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-167 BUG
    
    Change-Id: Id20ca1ee503f593460b99d9701c77c5c63d9d845
    Signed-off-by: haochen <haochen at multicorewareinc.com>
    Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>

diff --git a/sc/qa/unit/data/ods/opencl/math/BitLshift.ods b/sc/qa/unit/data/ods/opencl/math/BitLshift.ods
new file mode 100644
index 0000000..e1ebd4a
Binary files /dev/null and b/sc/qa/unit/data/ods/opencl/math/BitLshift.ods differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 9ee6b1b..ff65065 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -208,6 +208,7 @@ public:
     void testStatisticalFormulaSkew();
     void testMathFormulaArcTan2();
     void testMathFormulaBitOr();
+    void testMathFormulaBitLshift();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -347,6 +348,7 @@ public:
     CPPUNIT_TEST(testStatisticalFormulaSkew);
     CPPUNIT_TEST(testMathFormulaArcTan2);
     CPPUNIT_TEST(testMathFormulaBitOr);
+    CPPUNIT_TEST(testMathFormulaBitLshift);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -3765,6 +3767,29 @@ void ScOpenclTest::testStatisticalFormulaChiDist()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-167]
+void ScOpenclTest::testMathFormulaBitLshift()
+{
+    if (!detectOpenCLDevice())
+        return;
+    ScDocShellRef xDocSh = loadDoc("opencl/math/BitLshift.", ODS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/math/BitLshift.", ODS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    // Verify BitLshift Function
+    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-169]
 void ScOpenclTest::testMathFormulaFloor()
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 0f22c97..c1c9e89 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1440,6 +1440,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocSchiefe:
             case ocArcTan2:
             case ocBitOr:
+            case ocBitLshift:
             // Don't change the state.
             break;
             default:
commit f928820af4234725c98dd82e997ead2b1966a0dc
Author: yangzhang <yangzhang at multicorewareinc.com>
Date:   Sun Nov 10 10:02:00 2013 +0800

    GPU Calc: implemented BITLSHFIT
    
    AMLOEXT-167 FIX
    
    Change-Id: Ia91542a64c44d541114fee3c3655120d0350a286
    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 a958fbe..a761cc3 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1313,6 +1313,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 mvSubArguments.push_back(SoPHelper(ts,
                     ft->Children[i], new OpBitOr));
                 break;
+            case ocBitLshift:
+                mvSubArguments.push_back(SoPHelper(ts,
+                    ft->Children[i], new OpBitLshift));
+                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 5ba599d..c6e1f7e 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1422,7 +1422,50 @@ void OpBitOr::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "    return (long)num1 | (long)num2;\n";
     ss << "}";
 }
-
+void OpBitLshift::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 num = " << GetBottom() << ";\n";
+    ss << "    double shift_amount = " << GetBottom() << ";\n";
+#ifdef ISNAN
+    FormulaToken *iNum = vSubArguments[0]->GetFormulaToken();
+    const formula::SingleVectorRefToken* tmpCurDVRNum=
+        dynamic_cast<const formula::SingleVectorRefToken*>(iNum);
+    FormulaToken *iShiftAmount = vSubArguments[1]->GetFormulaToken();
+    const formula::SingleVectorRefToken* tmpCurDVRShiftAmount=
+        dynamic_cast<const formula::SingleVectorRefToken*>(iShiftAmount);
+    ss << "    int buffer_num_len = "<< tmpCurDVRNum->GetArrayLength()<<";\n";
+    ss << "    int buffer_shift_amount_len = ";
+    ss << tmpCurDVRShiftAmount->GetArrayLength() << ";\n";
+    ss << "    if((gid0)>=buffer_num_len || isNan(";
+    ss << vSubArguments[0]->GenSlidingWindowDeclRef() << "))\n";
+    ss << "        num = " << GetBottom() << ";\n";
+    ss << "    else\n    ";
+#endif
+    ss << "    num = floor(";
+    ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ");\n";
+#ifdef ISNAN
+    ss << "    if((gid0)>=buffer_shift_amount_len || isNan(";
+    ss << vSubArguments[1]->GenSlidingWindowDeclRef() << "))\n";
+    ss << "        shift_amount = " << GetBottom() << ";\n";
+    ss << "    else\n    ";
+#endif
+    ss << "    shift_amount = floor(";
+    ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ");\n";
+    ss << "    return floor(" << "shift_amount >= 0 ? ";
+    ss << "num * pow(2.0, shift_amount) : ";
+    ss << "num / pow(2.0, fabs(shift_amount)));\n";
+    ss << "}";
+}
 
 }}
 
diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx
index 20526d8..33cc6a2 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -175,6 +175,13 @@ public:
     virtual std::string GetBottom(void) { return "0.0"; }
     virtual std::string BinFuncName(void) const { return "ScBitOr"; }
 };
+class OpBitLshift:public Normal{
+public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+        const std::string sSymName, SubArguments &vSubArguments);
+    virtual std::string GetBottom(void) { return "0.0"; }
+    virtual std::string BinFuncName(void) const { return "ScBitLshift"; }
+};
 class OpLn: public CheckVariables
 {
 public:
commit dfbd51822f16e45036a198217863f670a7d8f609
Author: yangzhang <yangzhang at multicorewareinc.com>
Date:   Sun Nov 10 09:29:12 2013 +0800

    GPU Calc: unit test cases for BITOR
    
    Need to turn on NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-152 BUG
    
    Change-Id: Id29e7854452f93bdaf38490f484dea5af218bd56
    Signed-off-by: haochen <haochen at multicorewareinc.com>
    Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>

diff --git a/sc/qa/unit/data/ods/opencl/math/BitOr.ods b/sc/qa/unit/data/ods/opencl/math/BitOr.ods
new file mode 100644
index 0000000..517dcc1
Binary files /dev/null and b/sc/qa/unit/data/ods/opencl/math/BitOr.ods differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index e33599e..9ee6b1b 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -207,6 +207,7 @@ public:
     void testMathFormulaTrunc();
     void testStatisticalFormulaSkew();
     void testMathFormulaArcTan2();
+    void testMathFormulaBitOr();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -345,6 +346,7 @@ public:
     CPPUNIT_TEST(testMathFormulaTrunc);
     CPPUNIT_TEST(testStatisticalFormulaSkew);
     CPPUNIT_TEST(testMathFormulaArcTan2);
+    CPPUNIT_TEST(testMathFormulaBitOr);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -3417,6 +3419,32 @@ void ScOpenclTest::testStatisticalFormulaExpondist()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-152]
+void ScOpenclTest::testMathFormulaBitOr()
+{
+    if (!detectOpenCLDevice())
+        return;
+    ScDocShellRef xDocSh =
+        loadDoc("opencl/math/BitOr.", ODS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes =
+        loadDoc("opencl/math/BitOr.", ODS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    // Verify BitOr Function
+    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-153]
 void ScOpenclTest::testMathFormulaOdd()
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 4d85db0..0f22c97 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1439,6 +1439,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocTrunc:
             case ocSchiefe:
             case ocArcTan2:
+            case ocBitOr:
             // Don't change the state.
             break;
             default:
commit 328f788d6a047ac4291ce86fc7a4fb03b3fc93e5
Author: yangzhang <yangzhang at multicorewareinc.com>
Date:   Sun Nov 10 09:38:30 2013 +0800

    GPU Calc: implemented BITOR
    
    AMLOEXT-152 FIX
    
    Change-Id: I52747c3b2535e9bba3d167305a3ec5488a23411f
    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 b5de018..a958fbe 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1309,6 +1309,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 mvSubArguments.push_back(SoPHelper(ts,
                     ft->Children[i], new OpArcTan2));
                 break;
+            case ocBitOr:
+                mvSubArguments.push_back(SoPHelper(ts,
+                    ft->Children[i], new OpBitOr));
+                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 acf8534..5ba599d 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1381,7 +1381,47 @@ void OpFloor::GenSlidingWindowFunction(
     ss <<"        return trunc(arg0/arg1)*arg1;\n";
     ss << "}\n";
 }
-
+void OpBitOr::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 num1 = " << GetBottom() << ";\n";
+    ss << "    double num2 = " << GetBottom() << ";\n";
+#ifdef ISNAN
+    FormulaToken *iNum1 = vSubArguments[0]->GetFormulaToken();
+    const formula::SingleVectorRefToken* tmpCurDVRNum1=
+        dynamic_cast<const formula::SingleVectorRefToken *>(iNum1);
+    FormulaToken *iNum2 = vSubArguments[1]->GetFormulaToken();
+    const formula::SingleVectorRefToken* tmpCurDVRNum2=
+        dynamic_cast<const formula::SingleVectorRefToken *>(iNum2);
+    ss << "    int buffer_num1_len = "<<tmpCurDVRNum1->GetArrayLength()<<";\n";
+    ss << "    int buffer_num2_len = "<<tmpCurDVRNum2->GetArrayLength()<<";\n";
+    ss << "    if((gid0)>=buffer_num1_len || isNan(";
+    ss << vSubArguments[0]->GenSlidingWindowDeclRef() << "))\n";
+    ss << "        num1 = " << GetBottom() << ";\n";
+    ss << "    else \n    ";
+#endif
+    ss << "    num1 = floor(" << vSubArguments[0]->GenSlidingWindowDeclRef();
+    ss << ");\n";
+#ifdef ISNAN
+    ss << "    if((gid0)>=buffer_num2_len || isNan(";
+    ss << vSubArguments[1]->GenSlidingWindowDeclRef() << "))\n";
+    ss << "        num2 = " << GetBottom() << ";\n";
+    ss << "    else\n    ";
+#endif
+    ss << "    num2 = floor(" << vSubArguments[1]->GenSlidingWindowDeclRef();
+    ss << ");\n";
+    ss << "    return (long)num1 | (long)num2;\n";
+    ss << "}";
+}
 
 
 }}
diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx
index 71cb279..20526d8 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -168,6 +168,13 @@ public:
         virtual std::string GetBottom(void) { return "0.0"; }
     virtual std::string BinFuncName(void) const { return "ScBitAnd"; }
 };
+class OpBitOr:public Normal{
+public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+        const std::string sSymName, SubArguments &vSubArguments);
+    virtual std::string GetBottom(void) { return "0.0"; }
+    virtual std::string BinFuncName(void) const { return "ScBitOr"; }
+};
 class OpLn: public CheckVariables
 {
 public:
commit 2127b93fc8f9f306665c2f778761c7c60e2154fe
Author: yangzhang <yangzhang at multicorewareinc.com>
Date:   Sun Nov 10 09:20:22 2013 +0800

    GPU Calc: unit test cases for ATAN2
    
    Need to turn on NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-174 BUG
    
    Change-Id: I83e5d89079eb8f1dd315d23888e4d7058f48bcae
    Signed-off-by: haochen <haochen at multicorewareinc.com>
    Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>

diff --git a/sc/qa/unit/data/ods/opencl/math/ArcTan2.ods b/sc/qa/unit/data/ods/opencl/math/ArcTan2.ods
new file mode 100644
index 0000000..89f6bc5
Binary files /dev/null and b/sc/qa/unit/data/ods/opencl/math/ArcTan2.ods differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index ed13362..e33599e 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -206,6 +206,7 @@ public:
     void testMathFormulaMod();
     void testMathFormulaTrunc();
     void testStatisticalFormulaSkew();
+    void testMathFormulaArcTan2();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -343,6 +344,7 @@ public:
     CPPUNIT_TEST(testMathFormulaMod);
     CPPUNIT_TEST(testMathFormulaTrunc);
     CPPUNIT_TEST(testStatisticalFormulaSkew);
+    CPPUNIT_TEST(testMathFormulaArcTan2);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -3317,6 +3319,33 @@ void ScOpenclTest:: testFinacialNPER1Formula()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-147]
+void ScOpenclTest::testMathFormulaArcTan2()
+{
+    if (!detectOpenCLDevice())
+        return;
+    ScDocShellRef xDocSh =
+        loadDoc("opencl/math/ArcTan2.", ODS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes =
+        loadDoc("opencl/math/ArcTan2.", ODS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    // Verify ATan2 Function
+    for (SCROW i = 1; i <= 17; ++i)
+    {
+        double fLibre = pDoc->GetValue(ScAddress(2,i,0));
+        double fExcel = pDocRes->GetValue(ScAddress(2,i,0));
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, 0.000001);
+    }
+    xDocSh->DoClose();
+    xDocShRes->DoClose();
+}
+
+
 //[AMLOEXT-148]
 void ScOpenclTest::testStatisticalFormulaChiSqInv()
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 94a4ff0..4d85db0 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1438,6 +1438,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocMod:
             case ocTrunc:
             case ocSchiefe:
+            case ocArcTan2:
             // Don't change the state.
             break;
             default:
commit 095c0d95b0906135d83588ac75d2925c7ae27f6d
Author: yangzhang <yangzhang at multicorewareinc.com>
Date:   Sun Nov 10 09:23:34 2013 +0800

    GPU Calc: implemented ATAN2
    
    AMLOEXT-174 FIX
    
    Change-Id: I1dcff6d785c10fbc72f70bd0fc95f73859ef8452
    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 ce53e74..b5de018 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1305,6 +1305,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 mvSubArguments.push_back(SoPHelper(ts,
                          ft->Children[i], new OpSkew));
                 break;
+            case ocArcTan2:
+                mvSubArguments.push_back(SoPHelper(ts,
+                    ft->Children[i], new OpArcTan2));
+                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 f4e4f27..acf8534 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1037,6 +1037,45 @@ void OpArcSinHyp::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "    return asinh(tmp);\n";
     ss << "}";
 }
+void OpArcTan2::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 x_num = " << GetBottom() << ";\n";
+    ss << "    double y_num = " << GetBottom() << ";\n";
+#ifdef ISNAN
+    FormulaToken *iXNum = vSubArguments[0]->GetFormulaToken();
+    const formula::SingleVectorRefToken*tmpCurDVRX=
+        dynamic_cast<const formula::SingleVectorRefToken *>(iXNum);
+    FormulaToken *iYNum = vSubArguments[1]->GetFormulaToken();
+    const formula::SingleVectorRefToken*tmpCurDVRY=
+        dynamic_cast<const formula::SingleVectorRefToken *>(iYNum);
+    ss << "    int buffer_x_len = " << tmpCurDVRX->GetArrayLength() << ";\n";
+    ss << "    int buffer_y_len = " << tmpCurDVRY->GetArrayLength() << ";\n";
+    ss << "    if((gid0)>=buffer_x_len || isNan(";
+    ss << vSubArguments[0]->GenSlidingWindowDeclRef() << "))\n";
+    ss << "        x_num = " << GetBottom() << ";\n";
+    ss << "    else \n    ";
+#endif
+    ss << "    x_num = "<< vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
+#ifdef ISNAN
+    ss << "    if((gid0)>=buffer_y_len || isNan(";
+    ss << vSubArguments[1]->GenSlidingWindowDeclRef() << "))\n";
+    ss << "        y_num = " << GetBottom() << ";\n";
+    ss << "    else \n    ";
+#endif
+    ss << "    y_num = "<< vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
+    ss << "    return atan2(y_num, x_num);\n";
+    ss << "}";
+}
 void OpArcTan::GenSlidingWindowFunction(std::stringstream &ss,
     const std::string sSymName, SubArguments &vSubArguments)
 {
diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx
index 7d7a740..71cb279 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -140,6 +140,13 @@ public:
 
     virtual std::string BinFuncName(void) const { return "Trunc"; }
 };
+class OpArcTan2:public Normal{
+public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+        const std::string sSymName, SubArguments &vSubArguments);
+    virtual std::string GetBottom(void) { return "0.0"; }
+    virtual std::string BinFuncName(void) const { return "ScATan2"; }
+};
 class OpArcTan:public Normal{
 public:
     virtual void GenSlidingWindowFunction(std::stringstream &ss,
commit cc20e3b1b5c72739bd72fbb19b68d756d75abf86
Author: fengzeng <fengzeng at multicorewareinc.com>
Date:   Sun Nov 10 08:38:49 2013 +0800

    GPU Calc: unit test cases for SKEW
    
    Need to turn on NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-80 BUG
    
    Change-Id: I639318c1f431d7ed728d68e6b1ef66c2cac1b32f
    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/Skew.xls b/sc/qa/unit/data/xls/opencl/statistical/Skew.xls
new file mode 100644
index 0000000..1a58309
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/statistical/Skew.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 91413f7..ed13362 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -205,6 +205,7 @@ public:
     void testMathFormulaLog();
     void testMathFormulaMod();
     void testMathFormulaTrunc();
+    void testStatisticalFormulaSkew();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -341,6 +342,7 @@ public:
     CPPUNIT_TEST(testMathFormulaLog);
     CPPUNIT_TEST(testMathFormulaMod);
     CPPUNIT_TEST(testMathFormulaTrunc);
+    CPPUNIT_TEST(testStatisticalFormulaSkew);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1676,6 +1678,31 @@ void ScOpenclTest::testStatisticalFormulaVar()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-80]
+void ScOpenclTest::testStatisticalFormulaSkew()
+{
+    if (!detectOpenCLDevice())
+        return;
+
+    ScDocShellRef xDocSh = loadDoc("opencl/statistical/Skew.", XLS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+
+    ScDocShellRef xDocShRes = loadDoc("opencl/statistical/Skew.", 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-82]
 void ScOpenclTest::testStatisticalFormulaPearson()
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index f065e83..94a4ff0 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1437,6 +1437,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocLog:
             case ocMod:
             case ocTrunc:
+            case ocSchiefe:
             // Don't change the state.
             break;
             default:
commit 8e2df9ac2bb14f05b8b59741526f6cfa3d1c97fe
Author: fengzeng <fengzeng at multicorewareinc.com>
Date:   Sun Nov 10 09:03:29 2013 +0800

    GPU Calc: implemented for SKEW
    
    AMLOEXT-80 FIX
    
    Change-Id: I22131ff7688237c7cb77335d6a8cadd4e40ff78d
    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 ccdc01b..ce53e74 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1301,6 +1301,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 mvSubArguments.push_back(SoPHelper(ts,
                          ft->Children[i], new OpTrunc));
                 break;
+            case ocSchiefe:
+                mvSubArguments.push_back(SoPHelper(ts,
+                         ft->Children[i], new OpSkew));
+                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 a686e5d..636afd0 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -671,7 +671,346 @@ void OpWeibull::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "    return tmp;\n";
     ss << "}\n";
 }
+void OpSkew::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 << "    if(fCount <= 2)\n";
+            ss << "        return 0;\n";
+            ss << "    else\n";
+            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";

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list