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

shiming zhang shiming at multicorewareinc.com
Thu Dec 19 15:54:33 PST 2013


 sc/Library_scopencl.mk                              |    1 
 sc/qa/unit/data/ods/opencl/math/Quotient.ods        |binary
 sc/qa/unit/data/ods/opencl/math/sec.ods             |binary
 sc/qa/unit/data/ods/opencl/math/sech.ods            |binary
 sc/qa/unit/data/xls/opencl/addin/besselj.xls        |binary
 sc/qa/unit/data/xls/opencl/database/daverage.xls    |binary
 sc/qa/unit/data/xls/opencl/database/dcount.xls      |binary
 sc/qa/unit/data/xls/opencl/database/dcountA.xls     |binary
 sc/qa/unit/data/xls/opencl/database/dmax.xls        |binary
 sc/qa/unit/data/xls/opencl/database/dmin.xls        |binary
 sc/qa/unit/data/xls/opencl/database/dproduct.xls    |binary
 sc/qa/unit/data/xls/opencl/database/dstdev.xls      |binary
 sc/qa/unit/data/xls/opencl/database/dstdevp.xls     |binary
 sc/qa/unit/data/xls/opencl/database/dsum.xls        |binary
 sc/qa/unit/data/xls/opencl/database/dvar.xls        |binary
 sc/qa/unit/data/xls/opencl/database/dvarp.xls       |binary
 sc/qa/unit/data/xls/opencl/math/MROUND.xls          |binary
 sc/qa/unit/data/xls/opencl/math/averageif.xls       |binary
 sc/qa/unit/data/xls/opencl/math/countif.xls         |binary
 sc/qa/unit/data/xls/opencl/math/degrees.xls         |binary
 sc/qa/unit/data/xls/opencl/math/fact.xls            |binary
 sc/qa/unit/data/xls/opencl/math/int.xls             |binary
 sc/qa/unit/data/xls/opencl/math/iseven.xls          |binary
 sc/qa/unit/data/xls/opencl/math/isodd.xls           |binary
 sc/qa/unit/data/xls/opencl/math/radians.xls         |binary
 sc/qa/unit/data/xls/opencl/math/rounddown.xls       |binary
 sc/qa/unit/data/xls/opencl/math/roundup.xls         |binary
 sc/qa/unit/data/xls/opencl/math/seriessum.xls       |binary
 sc/qa/unit/data/xls/opencl/math/sumif.xls           |binary
 sc/qa/unit/data/xls/opencl/statistical/AverageA.xls |binary
 sc/qa/unit/data/xls/opencl/statistical/Maxa.xls     |binary
 sc/qa/unit/data/xls/opencl/statistical/Mina.xls     |binary
 sc/qa/unit/data/xls/opencl/statistical/StDevA.xls   |binary
 sc/qa/unit/data/xls/opencl/statistical/StDevPA.xls  |binary
 sc/qa/unit/data/xls/opencl/statistical/VarA.xls     |binary
 sc/qa/unit/data/xls/opencl/statistical/VarPA.xls    |binary
 sc/qa/unit/data/xls/opencl/statistical/counta.xls   |binary
 sc/qa/unit/opencl-test.cxx                          |  943 +++
 sc/source/core/opencl/formulagroupcl.cxx            |  320 +
 sc/source/core/opencl/op_addin.cxx                  |  202 
 sc/source/core/opencl/op_addin.hxx                  |   29 
 sc/source/core/opencl/op_database.cxx               | 1814 +++++++
 sc/source/core/opencl/op_database.hxx               |   90 
 sc/source/core/opencl/op_financial.cxx              | 1929 ++++---
 sc/source/core/opencl/op_math.cxx                   | 1312 ++++-
 sc/source/core/opencl/op_math.hxx                   |  116 
 sc/source/core/opencl/op_statistical.cxx            | 4858 ++++++++++++++++----
 sc/source/core/opencl/op_statistical.hxx            |   80 
 sc/source/core/opencl/opbase.hxx                    |    8 
 sc/source/core/opencl/opinlinefun_finacial.cxx      |  481 +
 sc/source/core/opencl/opinlinefun_statistical.cxx   |  494 +-
 sc/source/core/tool/token.cxx                       |   29 
 52 files changed, 10535 insertions(+), 2171 deletions(-)

New commits:
commit 18397efd14ba7a06a92f0f11f0f9b603e6d30c05
Author: shiming zhang <shiming at multicorewareinc.com>
Date:   Fri Dec 6 13:35:32 2013 +0800

    GPU Calc: Optimized TEST
    
    AMLOEXT-206
    
    Change-Id: Ibde6be7d2fba7f96912924396e17cc21e4c00826
    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/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx
index 9786682..44d9cf3 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -255,7 +255,16 @@ void OpVar::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "        return vSum * pow(fCount - 1.0,-1.0);\n";
     ss << "}\n";
 }
-
+void OpZTest::BinInlineFun(std::set<std::string>& decls,
+    std::set<std::string>& funs)
+{
+    decls.insert(phiDecl);
+    funs.insert(phi);
+    decls.insert(taylorDecl);
+    funs.insert(taylor);
+    decls.insert(gaussDecl);
+    funs.insert(gauss);
+}
 void OpZTest::GenSlidingWindowFunction(std::stringstream &ss,
             const std::string sSymName, SubArguments &vSubArguments)
 {
@@ -269,13 +278,13 @@ void OpZTest::GenSlidingWindowFunction(std::stringstream &ss,
     }
     ss << "){\n";
     ss << "    int gid0 = get_global_id(0);\n";
-    ss << "    double fSum=0.0;\n";
-    ss << "    double fSumSqr=0.0;\n";
-    ss << "    double mue=0.0;\n";
-    ss << "    double fCount=0.0;\n";
-    ss << "    double arg=0.0;\n";
-    ss << "    double sigma=0.0;\n";
-    ss << "    double mu=0.0;\n";
+    ss << "    double fSum = 0.0;\n";
+    ss << "    double fSumSqr = 0.0;\n";
+    ss << "    double mue = 0.0;\n";
+    ss << "    double fCount = 0.0;\n";
+    ss << "    double arg = 0.0;\n";
+    ss << "    double sigma = 0.0;\n";
+    ss << "    double mu = 0.0;\n";
     if(vSubArguments.size() == 1 || vSubArguments.size() == 0)
     {
         ss << "    return DBL_MAX;\n";
@@ -301,7 +310,7 @@ void OpZTest::GenSlidingWindowFunction(std::stringstream &ss,
                 ss << " && i < " << nCurWindowSize  << "; i++)\n";
                 ss << "    {\n";
 #else
-                ss << "gid0; i < "<< nCurWindowSize << "; i++)\n";
+                ss << "gid0; i < " << nCurWindowSize << "; i++)\n";
                 ss << "    {\n";
 #endif
             }
@@ -309,10 +318,10 @@ void OpZTest::GenSlidingWindowFunction(std::stringstream &ss,
             {
 #ifdef  ISNAN
                 ss << "0; i < " << pDVR->GetArrayLength();
-                ss << " && i < gid0+"<< nCurWindowSize << "; i++)\n";
+                ss << " && i < gid0+" << nCurWindowSize << "; i++)\n";
                 ss << "    {\n";
 #else
-                ss << "0; i < gid0+"<< nCurWindowSize << "; i++)\n";
+                ss << "0; i < gid0+" << nCurWindowSize << "; i++)\n";
                 ss << "    {\n";
 #endif
             }
@@ -320,20 +329,20 @@ void OpZTest::GenSlidingWindowFunction(std::stringstream &ss,
             {
 #ifdef  ISNAN
                 ss << "0; i + gid0 < " << pDVR->GetArrayLength();
-                ss << " &&  i < "<< nCurWindowSize << "; i++)\n";
+                ss << " &&  i < " << nCurWindowSize << "; i++)\n";
                 ss << "    {\n";
 #else
-                ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+                ss << "0; i < " << nCurWindowSize << "; i++)\n";
                 ss << "    {\n";
 #endif
             }
             else
             {
 #ifdef  ISNAN
-                ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+                ss << "0; i < " << pDVR->GetArrayLength() << "; i++)\n";
                 ss << "    {\n";
 #else
-                ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+                ss << "0; i < " << pDVR->GetArrayLength() << "; i++)\n";
                 ss << "    {\n";
 #endif
             }
@@ -345,13 +354,14 @@ void OpZTest::GenSlidingWindowFunction(std::stringstream &ss,
             ss << "            continue;\n";
 #endif
             ss << "        fSum += arg;\n";
-            ss << "        fSumSqr += arg*arg;\n";
-            ss << "        fCount += 1;\n";
+            ss << "        fSumSqr += arg * arg;\n";
+            ss << "        fCount += 1.0;\n";
             ss << "    }\n";
-            ss << "    if(fCount<=1.0)\n";
+            ss << "    if(fCount <= 1.0)\n";
             ss << "        return DBL_MAX;\n";
-            ss << "    mue=fSum/fCount;\n";
-            ss << "    sigma=(fSumSqr-fSum*fSum/fCount)/(fCount-1.0);\n";
+            ss << "    mue = fSum *pow(fCount,-1.0);\n";
+            ss << "    sigma = (fSumSqr-fSum*fSum*";
+            ss << "pow(fCount,-1.0))*pow(fCount-1.0,-1.0);\n";
         }
         else
         {
@@ -359,25 +369,22 @@ void OpZTest::GenSlidingWindowFunction(std::stringstream &ss,
             ss << "}\n";
             return ;
         }
-        if(ocPush==vSubArguments[1]->GetFormulaToken()->GetOpCode())
+        if(ocPush == vSubArguments[1]->GetFormulaToken()->GetOpCode())
         {
             if(pCur1->GetType() == formula::svSingleVectorRef)
             {
                 const formula::SingleVectorRefToken* pSVR =
-                    dynamic_cast< const formula::
-                        SingleVectorRefToken* >(pCur1);
+                    dynamic_cast<const formula::SingleVectorRefToken* >(pCur1);
                 assert(pSVR);
 #ifdef  ISNAN
                 ss << "    if (gid0 < " << pSVR->GetArrayLength() << ")\n";
                 ss << "    {\n";
-                ss << "        if (isNan(";
-                ss << vSubArguments[1]->GenSlidingWindowDeclRef() << "))\n";
-                ss << "            mu=0.0;\n";
-                ss << "        else\n";
 #endif
-                ss << "            mu=" ;
+                ss << "        mu = " ;
                 ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
 #ifdef ISNAN
+                ss << "        if (isNan(mu))\n";
+                ss << "            mu = 0.0;\n";
                 ss << "    }\n";
 #endif
 
@@ -395,11 +402,10 @@ void OpZTest::GenSlidingWindowFunction(std::stringstream &ss,
         }
         else
         {
-            ss << "    mu=" ;
+            ss << "    mu = " ;
             ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
         }
-        ss << "    return 0.5-(0.5 *erfc(-((mue-mu)/sqrt(sigma/fCount))";
-        ss << "* 0.7071067811865475)-0.5);\n";
+        ss << "    return 0.5 - gauss((mue-mu)/sqrt(sigma/fCount));\n";
         ss << "}\n";
         return ;
     }
@@ -424,7 +430,7 @@ void OpZTest::GenSlidingWindowFunction(std::stringstream &ss,
                 ss << " && i < " << nCurWindowSize  << "; i++)\n";
                 ss << "    {\n";
 #else
-                ss << "gid0; i < "<< nCurWindowSize << "; i++)\n";
+                ss << "gid0; i < " << nCurWindowSize << "; i++)\n";
                 ss << "    {\n";
 #endif
             }
@@ -432,10 +438,10 @@ void OpZTest::GenSlidingWindowFunction(std::stringstream &ss,
             {
 #ifdef  ISNAN
                 ss << "0; i < " << pDVR->GetArrayLength();
-                ss << " && i < gid0+"<< nCurWindowSize << "; i++)\n";
+                ss << " && i < gid0+" << nCurWindowSize << "; i++)\n";
                 ss << "    {\n";
 #else
-                ss << "0; i < gid0+"<< nCurWindowSize << "; i++)\n";
+                ss << "0; i < gid0+" << nCurWindowSize << "; i++)\n";
                 ss << "    {\n";
 #endif
             }
@@ -443,20 +449,20 @@ void OpZTest::GenSlidingWindowFunction(std::stringstream &ss,
             {
 #ifdef  ISNAN
                 ss << "0; i + gid0 < " << pDVR->GetArrayLength();
-                ss << " &&  i < "<< nCurWindowSize << "; i++)\n";
+                ss << " &&  i < " << nCurWindowSize << "; i++)\n";
                 ss << "    {\n";
 #else
-                ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+                ss << "0; i < " << nCurWindowSize << "; i++)\n";
                 ss << "    {\n";
 #endif
             }
             else
             {
 #ifdef  ISNAN
-                ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+                ss << "0; i < " << pDVR->GetArrayLength() << "; i++)\n";
                 ss << "    {\n";
 #else
-                ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+                ss << "0; i < " << pDVR->GetArrayLength() << "; i++)\n";
                 ss << "    {\n";
 #endif
             }
@@ -467,12 +473,12 @@ void OpZTest::GenSlidingWindowFunction(std::stringstream &ss,
             ss << "            continue;\n";
 #endif
             ss << "        fSum += arg;\n";
-            ss << "        fSumSqr += arg*arg;\n";
-            ss << "        fCount += 1;\n";
+            ss << "        fSumSqr += arg * arg;\n";
+            ss << "        fCount += 1.0;\n";
             ss << "    }\n";
-            ss << "    if(fCount<=1.0)\n";
+            ss << "    if(fCount <= 1.0)\n";
             ss << "        return DBL_MAX;\n";
-            ss << "    mue=fSum/fCount;\n";
+            ss << "    mue = fSum * pow(fCount,-1.0);\n";
         }
         else
         {
@@ -480,25 +486,22 @@ void OpZTest::GenSlidingWindowFunction(std::stringstream &ss,
             ss << "}\n";
             return ;
         }
-        if(ocPush==vSubArguments[1]->GetFormulaToken()->GetOpCode())
+        if(ocPush == vSubArguments[1]->GetFormulaToken()->GetOpCode())
         {
             if(pCur1->GetType() == formula::svSingleVectorRef)
             {
                 const formula::SingleVectorRefToken* pSVR1 =
-                    dynamic_cast< const formula::
-                        SingleVectorRefToken* >(pCur1);
+                    dynamic_cast<const formula::SingleVectorRefToken* >(pCur1);
                 assert(pSVR1);
 #ifdef  ISNAN
                 ss << "    if (gid0 < " << pSVR1->GetArrayLength() << ")\n";
                 ss << "    {\n";
-                ss << "        if (isNan(";
-                ss << vSubArguments[1]->GenSlidingWindowDeclRef() << "))\n";
-                ss << "            mu=0.0;\n";
-                ss << "        else\n";
 #endif
-                ss << "            mu=" ;
+                ss << "        mu = " ;
                 ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
 #ifdef ISNAN
+                ss << "        if (isNan(mu))\n";
+                ss << "            mu = 0.0;\n";
                 ss << "    }\n";
 #endif
             }
@@ -518,25 +521,22 @@ void OpZTest::GenSlidingWindowFunction(std::stringstream &ss,
             ss << "    mu=" ;
             ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
         }
-        if(ocPush==vSubArguments[2]->GetFormulaToken()->GetOpCode())
+        if(ocPush == vSubArguments[2]->GetFormulaToken()->GetOpCode())
         {
             if(pCur2->GetType() == formula::svSingleVectorRef)
             {
                 const formula::SingleVectorRefToken* pSVR2 =
-                    dynamic_cast< const formula::
-                        SingleVectorRefToken* >(pCur2);
+                    dynamic_cast<const formula::SingleVectorRefToken* >(pCur2);
                 assert(pSVR2);
 #ifdef  ISNAN
                 ss << "    if (gid0 < " << pSVR2->GetArrayLength() << ")\n";
                 ss << "    {\n";
-                ss << "        if (isNan(";
-                ss << vSubArguments[2]->GenSlidingWindowDeclRef() << "))\n";
-                ss << "            sigma=0.0;\n";
-                ss << "        else\n";
 #endif
-                ss << "            sigma=" ;
+                ss << "        sigma = " ;
                 ss << vSubArguments[2]->GenSlidingWindowDeclRef() << ";\n";
 #ifdef ISNAN
+                ss << "        if (isNan(sigma))\n";
+                ss << "            sigma = 0.0;\n";
                 ss << "    }\n";
 #endif
             }
@@ -553,14 +553,14 @@ void OpZTest::GenSlidingWindowFunction(std::stringstream &ss,
         }
         else
         {
-            ss << "    sigma=" ;
+            ss << "    sigma = " ;
             ss << vSubArguments[2]->GenSlidingWindowDeclRef() << ";\n";
         }
-        ss << "    return 0.5-(0.5 *erfc(-((mue-mu)*sqrt(fCount)/sigma)";
-        ss << " * 0.7071067811865475)-0.5);\n";
+        ss << "    return 0.5 - gauss((mue-mu)*sqrt(fCount)/sigma);\n";
         ss << "}\n";
     }
 }
+
 void OpTTest::BinInlineFun(std::set<std::string>& decls,
     std::set<std::string>& funs)
 {
diff --git a/sc/source/core/opencl/op_statistical.hxx b/sc/source/core/opencl/op_statistical.hxx
index 111141b..cdbc866 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -54,6 +54,7 @@ class OpZTest: 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 "ZTest"; }
 };
 class OpStDevP: public Normal
commit 838653741c1c5f59725dbdcd0c0a833ebd1db7c9
Author: shiming zhang <shiming at multicorewareinc.com>
Date:   Wed Dec 18 15:46:56 2013 +0800

    GPU Calc: unit test cases for besselj
    
    Turn  NO_FALLBACK_TO_SWINTERP on in  formulagroupcl.cxx for test
    
    AMLOEXT-378 BUG
    
    Change-Id: I1cbc041e1aa1899fa10931e7bfc3f8c8b43066f6
    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/addin/besselj.xls b/sc/qa/unit/data/xls/opencl/addin/besselj.xls
new file mode 100644
index 0000000..ddee1a3
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/addin/besselj.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 65528df..3a12674 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -283,6 +283,7 @@ public:
     void testMathFormulaSeriesSum();
     void testMathFormulaQuotient();
     void testMathFormulaSumIf();
+    void testAddInFormulaBesseLJ();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -496,6 +497,7 @@ public:
     CPPUNIT_TEST(testMathFormulaQuotient);
     CPPUNIT_TEST(testMathFormulaSeriesSum);
     CPPUNIT_TEST(testMathFormulaSumIf);
+    CPPUNIT_TEST(testAddInFormulaBesseLJ);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -5861,6 +5863,31 @@ void ScOpenclTest::testMathFormulaSumIf()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-378]
+void ScOpenclTest::testAddInFormulaBesseLJ()
+{
+    if (!detectOpenCLDevice())
+        return;
+
+    ScDocShellRef xDocSh = loadDoc("opencl/addin/besselj.", XLS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+
+    ScDocShellRef xDocShRes = loadDoc("opencl/addin/besselj.", XLS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    // Check the results of formula cells in the shared formula range.
+    for (SCROW i = 1; i <= 20; ++i)
+    {
+        double fLibre = pDoc->GetValue(ScAddress(2,i,0));
+        double fExcel = pDocRes->GetValue(ScAddress(2,i,0));
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+    }
+    xDocSh->DoClose();
+    xDocShRes->DoClose();
+}
 ScOpenclTest::ScOpenclTest()
       : ScBootstrapFixture( "/sc/qa/unit/data" )
 {
commit afcf84daa01a547db37b20bfc613297936fa65b6
Author: shiming zhang <shiming at multicorewareinc.com>
Date:   Wed Dec 18 15:47:52 2013 +0800

    GPU Calc: implemented besselj
    
    AMLOEXT-378 FIX
    
    Change-Id: Ie70185694f9e7ab3a955994948146b9adb60f650
    Signed-off-by: haochen <haochen at multicorewareinc.com>
    Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>

diff --git a/sc/Library_scopencl.mk b/sc/Library_scopencl.mk
index a126dd6..3e6b955 100644
--- a/sc/Library_scopencl.mk
+++ b/sc/Library_scopencl.mk
@@ -42,6 +42,7 @@ $(eval $(call gb_Library_add_exception_objects,scopencl,\
         sc/source/core/opencl/op_financial \
         sc/source/core/opencl/op_database \
         sc/source/core/opencl/op_math \
+        sc/source/core/opencl/op_addin \
         sc/source/core/opencl/op_statistical \
         sc/source/core/opencl/op_array \
         sc/source/core/opencl/op_logical \
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 35f040d..f404a0f 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -27,6 +27,7 @@
 #include "op_statistical.hxx"
 #include "op_array.hxx"
 #include "op_spreadsheet.hxx"
+#include "op_addin.hxx"
 /// CONFIGURATIONS
 // Comment out this to turn off FMIN and FMAX intrinsics
 #define USE_FMIN_FMAX 1
@@ -2819,6 +2820,12 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                     mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],
                         new OpSeriesSum));
                 }
+                else if ( !(pChild->GetExternal().compareTo(OUString(
+                    "com.sun.star.sheet.addin.Analysis.getBesselj"))))
+                {
+                    mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],
+                        new OpBesselj));
+                }
                 break;
 
             default:
diff --git a/sc/source/core/opencl/op_addin.cxx b/sc/source/core/opencl/op_addin.cxx
new file mode 100644
index 0000000..c8eb2e3
--- /dev/null
+++ b/sc/source/core/opencl/op_addin.cxx
@@ -0,0 +1,202 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "op_addin.hxx"
+
+#include "formulagroup.hxx"
+#include "document.hxx"
+#include "formulacell.hxx"
+#include "tokenarray.hxx"
+#include "compiler.hxx"
+#include "interpre.hxx"
+#include "formula/vectortoken.hxx"
+#include <sstream>
+
+using namespace formula;
+
+namespace sc { namespace opencl {
+
+void OpBesselj::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 = 0.0;\n";
+    ss << "    double N = 0.0;\n";
+    if(vSubArguments.size() != 2)
+    {
+        ss << "    return DBL_MAX;\n" << "}\n";
+        return ;
+    }
+    FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken();
+    assert(tmpCur0);
+    if(ocPush == vSubArguments[0]->GetFormulaToken()->GetOpCode())
+    {
+        if(tmpCur0->GetType() == formula::svSingleVectorRef)
+        {
+            const formula::SingleVectorRefToken*tmpCurSVR0 =
+                dynamic_cast<const formula::SingleVectorRefToken *>(tmpCur0);
+#ifdef  ISNAN
+            ss << "    if (gid0 < " << tmpCurSVR0->GetArrayLength() << ")\n";
+            ss << "    {\n";
+#endif
+            ss << "        x = ";
+            ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
+#ifdef  ISNAN
+            ss << "        if (isNan(x))\n";
+            ss << "            x = 0.0;\n";
+            ss << "    }\n";
+#endif
+        }
+        else if(tmpCur0->GetType() == formula::svDouble)
+        {
+            ss << "    x = " << tmpCur0->GetDouble() << ";\n";
+        }
+        else
+        {
+            ss << "    return DBL_MAX;\n" << "}\n";
+            return ;
+        }
+    }
+    else
+    {
+        ss << "    x = ";
+        ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
+    }
+
+    FormulaToken *tmpCur1 = vSubArguments[1]->GetFormulaToken();
+    assert(tmpCur1);
+    if(ocPush == vSubArguments[1]->GetFormulaToken()->GetOpCode())
+    {
+        if(tmpCur1->GetType() == formula::svSingleVectorRef)
+        {
+            const formula::SingleVectorRefToken*tmpCurSVR1 =
+                dynamic_cast<const formula::SingleVectorRefToken *>(tmpCur1);
+#ifdef  ISNAN
+            ss << "    if (gid0 < " << tmpCurSVR1->GetArrayLength() << ")\n";
+            ss << "    {\n";
+#endif
+            ss << "        N = ";
+            ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
+#ifdef  ISNAN
+            ss << "        if (isNan(N))\n";
+            ss << "            N = 0.0;\n";
+            ss << "    }\n";
+#endif
+        }
+        else if(tmpCur1->GetType() == formula::svDouble)
+        {
+            ss << "    N = " << tmpCur1->GetDouble() << ";\n";
+        }
+        else
+        {
+            ss << "    return DBL_MAX;\n" << "}\n";
+            return ;
+        }
+    }
+    else
+    {
+        ss << "    N = ";
+        ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
+    }
+    ss << "    double f_PI       = 3.1415926535897932385;\n";
+    ss << "    double f_2_DIV_PI = 2.0 / f_PI;\n";
+    ss << "    double f_PI_DIV_2 = f_PI / 2.0;\n";
+    ss << "    double f_PI_DIV_4 = f_PI / 4.0;\n";
+    ss << "    if( N < 0.0 )\n";
+    ss << "        return DBL_MAX;\n";
+    ss << "    if (x == 0.0)\n";
+    ss << "        return (N == 0.0) ? 1.0 : 0.0;\n";
+    ss << "    double fSign = ((int)N % 2 == 1 && x < 0.0) ? -1.0 : 1.0;\n";
+    ss << "    double fX = fabs(x);\n";
+    ss << "    double fMaxIteration = 9000000.0;\n";
+    ss << "    double fEstimateIteration = fX * 1.5 + N;\n";
+    ss << "    bool bAsymptoticPossible = pow(fX,0.4) > N;\n";
+    ss << "    if (fEstimateIteration > fMaxIteration)\n";
+    ss << "    {\n";
+    ss << "        if (bAsymptoticPossible)\n";
+    ss << "            return fSign * sqrt(f_2_DIV_PI/fX)";
+    ss << "* cos(fX-N*f_PI_DIV_2-f_PI_DIV_4);\n";
+    ss << "        else\n";
+    ss << "            return DBL_MAX;\n";
+    ss << "    }\n";
+    ss << "    double epsilon = 1.0e-15;\n";
+    ss << "    bool bHasfound = false;\n";
+    ss << "    double k= 0.0;\n";
+    ss << "    double  u ;\n";
+    ss << "    double m_bar;\n";
+    ss << "    double g_bar;\n";
+    ss << "    double g_bar_delta_u;\n";
+    ss << "    double g = 0.0;\n";
+    ss << "    double delta_u = 0.0;\n";
+    ss << "    double f_bar = -1.0;\n";
+    ss << "    if (N==0)\n";
+    ss << "    {\n";
+    ss << "        u = 1.0;\n";
+    ss << "        g_bar_delta_u = 0.0;\n";
+    ss << "        g_bar = - 2.0/fX; \n";
+    ss << "        delta_u = g_bar_delta_u / g_bar;\n";
+    ss << "        u = u + delta_u ;\n";
+    ss << "        g = -1.0 / g_bar; \n";
+    ss << "        f_bar = f_bar * g;\n";
+    ss << "        k = 2.0;\n";
+    ss << "    }\n";
+    ss << "    if (N!=0)\n";
+    ss << "    {\n";
+    ss << "        u=0.0;\n";
+    ss << "        for (k =1.0; k<= N-1; k = k + 1.0)\n";
+    ss << "        {\n";
+    ss << "            m_bar=2.0 * fmod(k-1.0, 2.0) * f_bar;\n";
+    ss << "            g_bar_delta_u = - g * delta_u - m_bar * u;\n";
+    ss << "            g_bar = m_bar - 2.0*k/fX + g;\n";
+    ss << "            delta_u = g_bar_delta_u / g_bar;\n";
+    ss << "            u = u + delta_u;\n";
+    ss << "            g = -1.0/g_bar;\n";
+    ss << "            f_bar=f_bar * g;\n";
+    ss << "        }\n";
+    ss << "        m_bar=2.0 * fmod(k-1.0, 2.0) * f_bar;\n";
+    ss << "        g_bar_delta_u = f_bar - g * delta_u - m_bar * u;\n";
+    ss << "        g_bar = m_bar - 2.0*k/fX + g;\n";
+    ss << "        delta_u = g_bar_delta_u / g_bar;\n";
+    ss << "        u = u + delta_u;\n";
+    ss << "        g = -1.0/g_bar;\n";
+    ss << "        f_bar = f_bar * g;\n";
+    ss << "        k = k + 1.0;\n";
+    ss << "    }\n";
+    ss << "    do\n";
+    ss << "    {\n";
+    ss << "        m_bar = 2.0 * fmod(k-1.0, 2.0) * f_bar;\n";
+    ss << "        g_bar_delta_u = - g * delta_u - m_bar * u;\n";
+    ss << "        g_bar = m_bar - 2.0*k/fX + g;\n";
+    ss << "        delta_u = g_bar_delta_u / g_bar;\n";
+    ss << "        u = u + delta_u;\n";
+    ss << "        g = -pow(g_bar,-1.0);\n";
+    ss << "        f_bar = f_bar * g;\n";
+    ss << "        bHasfound = (fabs(delta_u)<=fabs(u)*epsilon);\n";
+    ss << "        k = k + 1.0;\n";
+    ss << "    }\n";
+    ss << "    while (!bHasfound && k <= fMaxIteration);\n";
+    ss << "    if (bHasfound)\n";
+    ss << "        return u * fSign;\n";
+    ss << "    else\n";
+    ss << "        return DBL_MAX;\n";
+    ss << "}";
+}
+
+}}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/opencl/op_addin.hxx b/sc/source/core/opencl/op_addin.hxx
new file mode 100644
index 0000000..aebe23f
--- /dev/null
+++ b/sc/source/core/opencl/op_addin.hxx
@@ -0,0 +1,29 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef SC_OPENCL_OP_ADDIN_HXX
+#define SC_OPENCL_OP_ADDIN_HXX
+
+#include "opbase.hxx"
+
+namespace sc { namespace opencl {
+
+class OpBesselj: public Normal
+{
+public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+        const std::string sSymName, SubArguments &vSubArguments);
+    virtual std::string BinFuncName(void) const { return "Besselj"; }
+};
+
+}}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 32d1b4e0eaf25bfb01149156a8fce1a261cf27b8
Author: fengzeng <fengzeng at multicorewareinc.com>
Date:   Wed Dec 18 15:31:12 2013 +0800

    GPU Calc: unit test cases for SUMIF
    
    turn  NO_FALLBACK_TO_SWINTERP on in formulagroupcl.cxx for test
    
    AMLOEXT-377 BUG
    
    Change-Id: I0980604d643f3875e4dfe7dcd20f3cad186d72f6
    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/sumif.xls b/sc/qa/unit/data/xls/opencl/math/sumif.xls
new file mode 100644
index 0000000..ef8ef8c
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/math/sumif.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 9704e7f..65528df 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -282,6 +282,7 @@ public:
     void testMathFormulaMROUND();
     void testMathFormulaSeriesSum();
     void testMathFormulaQuotient();
+    void testMathFormulaSumIf();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -494,6 +495,7 @@ public:
     CPPUNIT_TEST(testMathFormulaMROUND);
     CPPUNIT_TEST(testMathFormulaQuotient);
     CPPUNIT_TEST(testMathFormulaSeriesSum);
+    CPPUNIT_TEST(testMathFormulaSumIf);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -5837,6 +5839,28 @@ void ScOpenclTest::testMathFormulaSeriesSum()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-377]
+void ScOpenclTest::testMathFormulaSumIf()
+{
+    if (!detectOpenCLDevice())
+            return;
+    ScDocShellRef xDocSh = loadDoc("opencl/math/sumif.", XLS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/math/sumif.", XLS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    for (SCROW i = 0; i <= 26; ++i)
+    {
+        double fLibre = pDoc->GetValue(ScAddress(2,i,0));
+        double fExcel = pDocRes->GetValue(ScAddress(2,i,0));
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+    }
+    xDocSh->DoClose();
+    xDocShRes->DoClose();
+}
 ScOpenclTest::ScOpenclTest()
       : ScBootstrapFixture( "/sc/qa/unit/data" )
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index a7b95e5..af4f142 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1504,6 +1504,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocStDevPA:
             case ocSecant:
             case ocSecantHyp:
+            case ocSumIf:
             // Don't change the state.
             break;
             default:
commit 0d251fa34e2c98e95e5f5bbb0bcc10ded2a76168
Author: fengzeng <fengzeng at multicorewareinc.com>
Date:   Wed Dec 18 15:36:12 2013 +0800

    GPU Calc: implemented SUMIF
    
    AMLOEXT-377 FIX
    
    Change-Id: I2e656e9d943179b4da1c1b104ac77f0edcb2f86e
    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 ddfb665..35f040d 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -2585,6 +2585,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 mvSubArguments.push_back(SoPHelper(ts,
                          ft->Children[i], new OpSecH));
                 break;
+            case ocSumIf:
+                mvSubArguments.push_back(SoPHelper(ts,
+                         ft->Children[i], new OpSumIf));
+                 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 d27476d..0df3837 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1905,6 +1905,157 @@ void OpCountIf::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "    return varc;\n";
     ss << "}";
 }
+void OpSumIf::GenSlidingWindowFunction(std::stringstream &ss,
+    const std::string sSymName, SubArguments &vSubArguments)
+{
+    ss << "\ndouble " << sSymName;
+    ss << "_"<< BinFuncName() <<"(";
+    int flag = 0;
+    (3 == vSubArguments.size()) && (flag = 2);
+    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 vara, varb, varc, sum = 0.0f;\n";
+    FormulaToken *tmpCur = vSubArguments[1]->GetFormulaToken();
+    assert(tmpCur);
+    if(ocPush == vSubArguments[1]->GetFormulaToken()->GetOpCode())
+    {
+        if(tmpCur->GetType() == formula::svSingleVectorRef)
+        {
+            const formula::SingleVectorRefToken* tmpCurDVR=
+                dynamic_cast<
+                const formula::SingleVectorRefToken *>(tmpCur);
+            ss << "    varb = ";
+            ss << vSubArguments[1]->GenSlidingWindowDeclRef();
+            ss << ";\n";
+#ifdef ISNAN
+            ss << "    if(isNan(varb)||(gid0>=";
+            ss << tmpCurDVR->GetArrayLength();
+            ss << "))\n";
+            ss << "        varb = 0;\n";
+#endif
+        }
+        else if(tmpCur->GetType() == formula::svDouble)
+        {
+            ss << "    varb = ";
+            ss << tmpCur->GetDouble() << ";\n";
+        }
+    }
+    else
+    {
+        ss << "    varb = ";
+        ss << vSubArguments[1]->GenSlidingWindowDeclRef();
+        ss << ";\n";
+    }
+    tmpCur = vSubArguments[0]->GetFormulaToken();
+    assert(tmpCur);
+    if(ocPush == vSubArguments[0]->GetFormulaToken()->GetOpCode())
+    {
+        //TODO       DoubleVector
+        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 << "        vara = ";
+            ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+            ss << ";\n";
+#ifdef  ISNAN
+            ss << "        if (isNan(vara))\n";
+            ss << "            continue;\n";
+#endif
+            ss << "        varc = ";
+            ss << vSubArguments[flag]->GenSlidingWindowDeclRef();
+            ss << ";\n";
+#ifdef  ISNAN
+            ss << "        if (isNan(varc))\n";
+            ss << "            varc = 0.0f;\n";
+#endif
+            ss << "        (vara == varb)&&(sum = sum + varc);\n";
+            ss << "    }\n";
+        }
+        else if(tmpCur->GetType() == formula::svSingleVectorRef)
+        {
+            const formula::SingleVectorRefToken* tmpCurDVR=
+                dynamic_cast<
+                const formula::SingleVectorRefToken *>(tmpCur);
+            ss << "    vara = ";
+            ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+            ss << ";\n";
+#ifdef ISNAN
+            ss << "    if(isNan(vara)||(gid0>=";
+            ss << tmpCurDVR->GetArrayLength();
+            ss << "))\n";
+            ss << "        return 0;\n";
+#endif
+            ss << "    int i = 0;\n";
+            ss << "    varc = ";
+            ss << vSubArguments[flag]->GenSlidingWindowDeclRef();
+            ss << ";\n";
+#ifdef ISNAN
+            ss << "    if(isNan(varc)||(gid0>=";
+            ss << tmpCurDVR->GetArrayLength();
+            ss << "))\n";
+            ss << "        varc = 0.0f;\n";
+#endif
+
+            ss << "        (vara == varb)&&(sum = sum + varc);\n";
+
+        }
+    }
+    ss << "    return sum;\n";
+    ss << "}";
+}
 void OpTrunc::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 79a31d0..b0d7980 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -468,6 +468,13 @@ public:
             const std::string sSymName, SubArguments &vSubArguments);
     virtual std::string BinFuncName(void) const { return "SeriesSum"; }
 };
+class OpSumIf: public Normal
+{
+public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+            const std::string sSymName, SubArguments &vSubArguments);
+    virtual std::string BinFuncName(void) const { return "SumIf"; }
+};
 class OpQuotient: public Normal
 {
 public:
commit 2013375890bf75f1b5dea529bd011880c7402ea6
Author: fengzeng <fengzeng at multicorewareinc.com>
Date:   Tue Dec 17 17:08:20 2013 +0800

    GPU Calc: Fix bug of TRUNC
    
    AMLOEXT-365
    
    Change-Id: I968ca9cc202706698a3fc5e957c4941c234779f7
    Signed-off-by: haochen <haochen at multicorewareinc.com>
    Signed-off-by: Wei Wei <weiwei at multicorewareinc.com>
    Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>

diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx
index 9e676a4..d27476d 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1974,13 +1974,16 @@ void OpTrunc::GenSlidingWindowFunction(std::stringstream &ss,
             ss << ";\n";
         }
     }
+    ss << "    double argm = arg[0];\n";
     ss << "    int n = (int)arg[1];\n";
-    ss << "    int nn = 1;\n";
-    ss << "    for(int i=0; i<n; ++i)\n";
-    ss << "        nn *= 10;\n";
-    ss << "    n = (int)(arg[0] * nn);\n";
-    ss << "    arg[0] = (double)n / nn;\n";
-    ss << "    return arg[0];\n";
+    ss << "    double nn = 1.0f;\n";
+    ss << "    for(int i = 0; i < n; ++i)\n";
+    ss << "    {\n";
+    ss << "        argm = argm * 10;\n";
+    ss << "        nn = nn * 10;\n";
+    ss << "    }\n";
+    ss << "    modf(argm, &argm);\n";
+    ss << "    return argm / nn;\n";
     ss << "}";
 }
 void OpFloor::GenSlidingWindowFunction(
commit 774b8342ac15cdb06e9069cfac19c982ec6ca79e
Author: yangzhang <yangzhang at multicorewareinc.com>
Date:   Tue Dec 17 14:19:48 2013 +0800

    GPU Calc: Fixed accuracy bug of CEILING
    
    AMLOEXT-375 FIX
    
    Change-Id: Ie41c66570db2c9b752d987de421bb7310b244611
    Signed-off-by: haochen <haochen at multicorewareinc.com>
    Signed-off-by: Wei Wei <weiwei at multicorewareinc.com>
    Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>

diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx
index 4fc7b3c..9e676a4 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -2386,24 +2386,17 @@ void OpCeil::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "    double bAbs = 0;\n";
 #ifdef ISNAN
     FormulaToken *iNum = vSubArguments[0]->GetFormulaToken();
-    const formula::SingleVectorRefToken* tmpCurDVRNum=
-        dynamic_cast<const formula::SingleVectorRefToken*>(iNum);
     FormulaToken *iSignificance = vSubArguments[1]->GetFormulaToken();
-    const formula::SingleVectorRefToken* tmpCurDVRSignificance=
-        dynamic_cast<const formula::SingleVectorRefToken*>(iSignificance);
-    ss << "    int buffer_num_len = "<<tmpCurDVRNum->GetArrayLength() << ";\n";
-    ss << "    int buffer_significance_len = ";
-    ss << tmpCurDVRSignificance->GetArrayLength() << ";\n";
-    ss << "    if((gid0)>=buffer_num_len || isNan(";
+    ss << "    if(isNan(";
     ss << vSubArguments[0]->GenSlidingWindowDeclRef() << "))\n";
     ss << "        num = " << GetBottom() << ";\n";
     ss << "    else\n    ";
 #endif
     ss << "    num = " << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
 #ifdef ISNAN
-    ss << "    if((gid0)>=buffer_significance_len || isNan(";
+    ss << "    if(isNan(";
     ss << vSubArguments[1]->GenSlidingWindowDeclRef() << "))\n";
-    ss << "        significance = " << GetBottom() << ";\n";
+    ss << "        return 0.0;\n";
     ss << "    else\n    ";
 #endif
     ss << "    significance = ";
@@ -2435,6 +2428,8 @@ void OpCeil::GenSlidingWindowFunction(std::stringstream &ss,
 #endif
         ss << "    bAbs = "<<vSubArguments[2]->GenSlidingWindowDeclRef()<<";\n";
     }
+    ss << "    if(significance == 0.0)\n";
+    ss << "        return 0.0;\n";
     ss << "    return ";
     ss << "( !(int)bAbs && num < 0.0 ? floor( num / significance ) : ";
     ss << "ceil( num / significance ) )";
commit 1f0b4ad3341af3c6f3c309a303bd3008debcb9b3
Author: yangzhang <yangzhang at multicorewareinc.com>
Date:   Tue Dec 17 14:16:26 2013 +0800

    GPU Calc: Fixed accuracy bug of BitAnd
    
    AMLOEXT-374 FIX
    
    Change-Id: I3deec32d09058483043211d920519bb4fd1e7018
    Signed-off-by: haochen <haochen at multicorewareinc.com>
    Signed-off-by: Wei Wei <weiwei at multicorewareinc.com>
    Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>

diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx
index 53d2ce7..4fc7b3c 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1527,7 +1527,7 @@ void OpBitAnd::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "    else \n    ";
 #endif
     ss << "    num2 = " << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
-    ss << "    return (int)num1 & (int)num2;\n";
+    ss << "    return (long)num1 & (long)num2;\n";
     ss << "}";
 }
 void OpLn::GenSlidingWindowFunction(
commit 0016999b43fe9b3b60dda68132668c9b174d2598
Author: yangzhang <yangzhang at multicorewareinc.com>
Date:   Tue Dec 17 11:53:13 2013 +0800

    GPU Calc: unit test cases for SERIESSUM
    
    Need turn macro NO_FALLBACK_TO_SWINTERP on  formulagroupcl.cxx for test
    
    AMLOEXT-373 BUG
    
    Change-Id: Id30d16c46d33e18f347682946f18b5c82aef2158
    Signed-off-by: haochen <haochen at multicorewareinc.com>
    Signed-off-by: Wei Wei <weiwei at multicorewareinc.com>
    Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>

diff --git a/sc/qa/unit/data/xls/opencl/math/seriessum.xls b/sc/qa/unit/data/xls/opencl/math/seriessum.xls
new file mode 100644
index 0000000..14104ac
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/math/seriessum.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index ec7ce13..9704e7f 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -280,6 +280,7 @@ public:
     void testMathFormulaSEC();
     void testMathFormulaSECH();
     void testMathFormulaMROUND();
+    void testMathFormulaSeriesSum();
     void testMathFormulaQuotient();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
@@ -492,6 +493,7 @@ public:
     CPPUNIT_TEST(testMathFormulaSECH);
     CPPUNIT_TEST(testMathFormulaMROUND);
     CPPUNIT_TEST(testMathFormulaQuotient);
+    CPPUNIT_TEST(testMathFormulaSeriesSum);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -5813,6 +5815,28 @@ void ScOpenclTest::testMathFormulaQuotient()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-373]
+void ScOpenclTest::testMathFormulaSeriesSum()
+{
+    if (!detectOpenCLDevice())
+            return;
+    ScDocShellRef xDocSh = loadDoc("opencl/math/seriessum.", XLS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/math/seriessum.", XLS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    for (SCROW i = 0; i <= 15; ++i)
+    {
+        double fLibre = pDoc->GetValue(ScAddress(1,i,0));
+        double fExcel = pDocRes->GetValue(ScAddress(1,i,0));
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+    }
+    xDocSh->DoClose();
+    xDocShRes->DoClose();
+}
 ScOpenclTest::ScOpenclTest()
       : ScBootstrapFixture( "/sc/qa/unit/data" )
 {
commit 14294525adf96f3da84f434e4a949332e6bab31d
Author: yangzhang <yangzhang at multicorewareinc.com>
Date:   Tue Dec 17 11:54:08 2013 +0800

    GPU Calc: implemented SERIESSUM
    
    AMLOEXT-373 FIX
    
    Change-Id: I23926b7a390dbdb44e7f897d2079d9baf4befd02
    Signed-off-by: haochen <haochen at multicorewareinc.com>
    Signed-off-by: Wei Wei <weiwei 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 1cf6a47..ddfb665 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -2809,6 +2809,12 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                     mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],
                         new OpQuotient));
                 }
+                else if ( !(pChild->GetExternal().compareTo(OUString(
+                    "com.sun.star.sheet.addin.Analysis.getSeriessum"))))
+                {
+                    mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],
+                        new OpSeriesSum));
+                }
                 break;
 
             default:
diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx
index cb3b2df..53d2ce7 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -2891,6 +2891,143 @@ void OpQuotient::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "    return trunc(num1/num2);\n";
     ss << "}";
 }
+void OpSeriesSum::GenSlidingWindowFunction(std::stringstream &ss,
+    const std::string sSymName, SubArguments &vSubArguments)
+{
+    if( vSubArguments.size() != 4){return;}
+    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 var[3], coeff, res = 0.0f;\n";
+    FormulaToken *tmpCur;
+    for(int i = 0; i < 3; ++i)
+    {
+        tmpCur = vSubArguments[i]->GetFormulaToken();
+        assert(tmpCur);
+        if(ocPush == vSubArguments[i]->GetFormulaToken()->GetOpCode())
+        {
+            if(tmpCur->GetType() == formula::svSingleVectorRef)
+            {
+                const formula::SingleVectorRefToken* tmpCurDVR=
+                    dynamic_cast<
+                    const formula::SingleVectorRefToken *>(tmpCur);
+                ss << "    var["<<i<<"] = ";
+                ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+                ss << ";\n";
+#ifdef ISNAN
+                ss << "    if(isNan(var["<<i<<"])||(gid0>=";
+                ss << tmpCurDVR->GetArrayLength();
+                ss << "))\n";
+                ss << "        var["<<i<<"] = 0;\n";
+#endif
+            }
+            else if(tmpCur->GetType() == formula::svDouble)
+            {
+                ss << "    var["<<i<<"] = ";
+                ss << tmpCur->GetDouble() << ";\n";
+            }
+        }
+        else
+        {
+            ss << "    var["<<i<<"] = ";
+            ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss << ";\n";
+        }
+    }
+    tmpCur = vSubArguments[3]->GetFormulaToken();
+    assert(tmpCur);
+    if(ocPush == vSubArguments[3]->GetFormulaToken()->GetOpCode())
+    {
+        //TODO       DoubleVector
+        if (tmpCur->GetType() == formula::svDoubleVectorRef)
+        {
+            const formula::DoubleVectorRefToken* pDVR =
+                dynamic_cast<const formula::DoubleVectorRefToken *>(tmpCur);
+            size_t nCurWindowSize = pDVR->GetRefRowSize();
+            ss << "    int j = 0;\n";
+            ss << "    for (int i = ";
+            if (!pDVR->IsStartFixed() && pDVR->IsEndFixed())
+            {
+#ifdef  ISNAN
+                ss << "gid0; i < " << pDVR->GetArrayLength();
+                ss << " && i < " << nCurWindowSize  << "; ++i)\n";
+                ss << "    {\n";
+#else
+                ss << "gid0; i < "<< nCurWindowSize << "; ++i)\n";
+                ss << "    {\n";
+#endif
+            }
+            else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+            {
+#ifdef  ISNAN
+                ss << "0; i < " << pDVR->GetArrayLength();
+                ss << " && i < gid0+"<< nCurWindowSize << "; ++i)\n";
+                ss << "    {\n";
+#else
+                ss << "0; i < gid0+"<< nCurWindowSize << "; ++i)\n";
+                ss << "    {\n";
+#endif
+            }
+            else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+            {
+#ifdef  ISNAN
+                ss << "0; i + gid0 < " << pDVR->GetArrayLength();
+                ss << " &&  i < "<< nCurWindowSize << "; ++i)\n";
+                ss << "    {\n";
+#else
+                ss << "0; i < "<< nCurWindowSize << "; ++i)\n";
+                ss << "    {\n";
+#endif
+            }
+            else
+            {
+#ifdef  ISNAN
+                ss << "0; i < "<< nCurWindowSize << "; ++i)\n";
+                ss << "    {\n";
+#else
+                ss << "0; i < "<< nCurWindowSize << "; ++i)\n";
+                ss << "    {\n";
+#endif
+            }
+            ss << "        coeff = ";
+            ss << vSubArguments[3]->GenSlidingWindowDeclRef();
+            ss << ";\n";
+#ifdef  ISNAN
+            ss << "        if (isNan(coeff))\n";
+            ss << "            continue;\n";
+#endif
+            ss << "        res = res + coeff * pow(var[0],";
+            ss << " var[1] + j * var[2]);\n";
+            ss << "        ++j;\n";
+            ss << "    }\n";
+        }
+        else if(tmpCur->GetType() == formula::svSingleVectorRef)
+        {
+            const formula::SingleVectorRefToken* tmpCurDVR=
+                dynamic_cast<
+                const formula::SingleVectorRefToken *>(tmpCur);
+            ss << "    coeff = ";
+            ss << vSubArguments[3]->GenSlidingWindowDeclRef();
+            ss << ";\n";
+#ifdef ISNAN
+            ss << "    if(isNan(coeff)||(gid0>=";
+            ss << tmpCurDVR->GetArrayLength();
+            ss << "))\n";
+            ss << "        return 0;\n";
+#endif
+        }
+    }
+    ss << "    return res;\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 7d61ce7..79a31d0 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -461,6 +461,13 @@ public:
     virtual std::string GetBottom(void) { return "0.0"; }
     virtual std::string BinFuncName(void) const { return "Fact"; }
 };
+class OpSeriesSum: public Normal
+{
+public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+            const std::string sSymName, SubArguments &vSubArguments);
+    virtual std::string BinFuncName(void) const { return "SeriesSum"; }
+};
 class OpQuotient: public Normal
 {
 public:
commit db3ff40e35216ad60c8d427415369a919c86a364
Author: yangzhang <yangzhang at multicorewareinc.com>
Date:   Tue Dec 17 10:02:38 2013 +0800

    GPU Calc: unit test cases for QUOTIENT
    
    Need turn macro NO_FALLBACK_TO_SWINTERP on  formulagroupcl.cxx for test
    
    AMLOEXT-372 BUG
    
    Change-Id: Ife2681e8c637cf8d17e3db2072f725e25ad85434
    Signed-off-by: haochen <haochen at multicorewareinc.com>
    Signed-off-by: Wei Wei <weiwei at multicorewareinc.com>
    Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>

diff --git a/sc/qa/unit/data/ods/opencl/math/Quotient.ods b/sc/qa/unit/data/ods/opencl/math/Quotient.ods
new file mode 100644
index 0000000..28242f0
Binary files /dev/null and b/sc/qa/unit/data/ods/opencl/math/Quotient.ods differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 53db504..ec7ce13 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -280,6 +280,7 @@ public:
     void testMathFormulaSEC();
     void testMathFormulaSECH();
     void testMathFormulaMROUND();
+    void testMathFormulaQuotient();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -490,6 +491,7 @@ public:
     CPPUNIT_TEST(testMathFormulaSEC);
     CPPUNIT_TEST(testMathFormulaSECH);
     CPPUNIT_TEST(testMathFormulaMROUND);
+    CPPUNIT_TEST(testMathFormulaQuotient);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -5786,6 +5788,31 @@ void ScOpenclTest::testMathFormulaMROUND()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-372]
+void ScOpenclTest::testMathFormulaQuotient()
+{
+    if (!detectOpenCLDevice())
+        return;
+    ScDocShellRef xDocSh =
+        loadDoc("opencl/math/Quotient.", ODS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes =
+        loadDoc("opencl/math/Quotient.", ODS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    // Verify BitAnd 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();
+}
 ScOpenclTest::ScOpenclTest()
       : ScBootstrapFixture( "/sc/qa/unit/data" )
 {
commit 67cd5265b2ea8f990533e46d46f7b6386a527e3a
Author: yangzhang <yangzhang at multicorewareinc.com>
Date:   Tue Dec 17 10:04:58 2013 +0800

    GPU Calc: implemented QUOTIENT
    
    AMLOEXT-372 FIX
    
    Change-Id: Iaa8c1a4d64007071997f5eccdacf76be7f531894
    Signed-off-by: haochen <haochen at multicorewareinc.com>
    Signed-off-by: Wei Wei <weiwei 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 aa34d76..1cf6a47 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -2803,7 +2803,12 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                     mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],
                         new OpMROUND));
                 }
-                break;
+                else if ( !(pChild->GetExternal().compareTo(OUString(
+                    "com.sun.star.sheet.addin.Analysis.getQuotient"))))
+                {
+                    mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],
+                        new OpQuotient));
+                }
                 break;
 
             default:
diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx
index 504f616..cb3b2df 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -2858,6 +2858,39 @@ void OpFact::GenSlidingWindowFunction(std::stringstream& ss,
     ss << "    return arg0;\n";
     ss << "}";
 }
+void OpQuotient::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 = 1.0;\n";
+    ss << "    double num2 = 1.0;\n";
+#ifdef ISNAN
+    FormulaToken *iNum1 = vSubArguments[0]->GetFormulaToken();
+    FormulaToken *iNum2 = vSubArguments[1]->GetFormulaToken();
+    ss << "    if(isNan(";
+    ss << vSubArguments[0]->GenSlidingWindowDeclRef() << "))\n";
+    ss << "        num1 = 1.0;\n";
+    ss << "    else \n    ";
+#endif
+    ss << "    num1 = " << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
+#ifdef ISNAN
+    ss << "    if(isNan(";
+    ss << vSubArguments[1]->GenSlidingWindowDeclRef() << "))\n";
+    ss << "        num2 = 1.0;\n";
+    ss << "    else \n    ";
+#endif
+    ss << "    num2 = " << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
+    ss << "    return trunc(num1/num2);\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 c2dccb2..7d61ce7 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -461,6 +461,13 @@ public:
     virtual std::string GetBottom(void) { return "0.0"; }
     virtual std::string BinFuncName(void) const { return "Fact"; }
 };
+class OpQuotient: public Normal
+{
+public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+        const std::string sSymName, SubArguments &vSubArguments);
+    virtual std::string BinFuncName(void) const { return "Quotient"; }
+};
 }}
 
 #endif
commit 2009d74a2f610f5a656f778b458866fa079b38f7
Author: mingli <mingli at multicorewareinc.com>
Date:   Mon Dec 16 15:58:55 2013 +0800

    GPU Calc:Fix the accuracy problem of 'Harmean'
    
    AMLOEXT-366
    
    Change-Id: Ic368b8301c4e80ad76e1d0b33b69bee6a87b9d89
    Signed-off-by: haochen <haochen at multicorewareinc.com>
    Signed-off-by: Wei Wei <weiwei at multicorewareinc.com>
    Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>

diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx
index 43dd939..9786682 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -4381,11 +4381,7 @@ void OpHarMean::GenSlidingWindowFunction(
     std::stringstream &ss, const std::string sSymName, SubArguments &
 vSubArguments)
 {
-    FormulaToken *pCur = vSubArguments[0]->GetFormulaToken();
-    assert(pCur);
-    const formula::DoubleVectorRefToken* pCurDVR =
-        dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
-    size_t nCurWindowSize = pCurDVR->GetRefRowSize();
+
     ss << "\ndouble " << sSymName;
     ss << "_"<< BinFuncName() <<"( ";
     for (unsigned i = 0; i < vSubArguments.size(); i++)
@@ -4394,23 +4390,27 @@ vSubArguments)
             ss << ",";
         vSubArguments[i]->GenSlidingWindowDecl(ss);
     }
-    ss << ") {\n";
+    ss << ")\n";
+    ss <<"{\n";
     ss << "    int gid0 = get_global_id(0);\n";
     ss << "    double nVal=0.0;\n";
-    ss << "    int length="<<nCurWindowSize<<";\n";
     ss << "    double tmp = 0;\n";
+    ss << "    int length;\n";
+    ss << "    int totallength=0;\n";
     for (unsigned i = 0; i < vSubArguments.size(); i++)
     {
-        pCur = vSubArguments[i]->GetFormulaToken();
+        FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
         assert(pCur);
         if (pCur->GetType() == formula::svDoubleVectorRef)
         {
             const formula::DoubleVectorRefToken* pDVR =
             dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
-            nCurWindowSize = pDVR->GetRefRowSize();
+            size_t nCurWindowSize = pDVR->GetRefRowSize();
+            ss << "    length="<<nCurWindowSize;
+            ss << ";\n";
             ss << "    for (int i = ";
-#ifdef  ISNAN
-            ss << "0; i < "<< nCurWindowSize << "; i++){\n";
+            ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+            ss << "    {\n";
             ss << "        double arg"<<i<<" = ";
             ss << vSubArguments[i]->GenSlidingWindowDeclRef();
             ss << ";\n";
@@ -4423,24 +4423,35 @@ vSubArguments)
             ss << "            continue;\n";
             ss << "        }\n";
 #endif
-            ss << "        nVal += pow(arg"<<i<<",-1);\n";
+            ss << "        nVal += (1.0 *pow(";
+            ss << " arg"<<i<<",-1));\n";
             ss << "    }\n";
-#endif
+            ss << "    totallength +=length;\n";
         }
         else if (pCur->GetType() == formula::svSingleVectorRef)
         {
-#ifdef  ISNAN
-            ss << "return HUGE_VAL";
+            ss << "    double arg0 = ";
+            ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss << ";\n";
+#ifdef ISNAN
+            ss << "    if(isNan(arg0))\n";
+            ss << "    {\n";
+            ss << "        continue;\n";
+            ss << "    }\n";
 #endif
+            ss << "    nVal += (1.0 * pow( arg0,-1));\n";
+            ss << "    totallength +=1;\n";
         }
         else if (pCur->GetType() == formula::svDouble)
         {
-#ifdef  ISNAN
-            ss << "return HUGE_VAL";
-#endif
+           ss << "    double arg0 = ";
+           ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+           ss << ";\n";
+           ss << "    nVal += (1.0 *pow( arg0,-1));\n";
+           ss << "    totallength +=1;\n";
         }
     }
-    ss << "    tmp = length/nVal;\n\t";
+    ss << "    tmp = totallength*pow(nVal,-1);\n";
     ss << "    return tmp;\n";
     ss << "}";
 }
commit 436fe90db05317e31c855e1ea01b3c4263784f07
Author: mulei <mulei at multicorewareinc.com>
Date:   Mon Dec 16 12:02:33 2013 +0800

    GPU Calc: unit test cases for MROUND
    
    Turn   NO_FALLBACK_TO_SWINTERP  on in formulagroupcl.cxx for test
    
    AMLOEXT-369 BUG
    
    Change-Id: If0bf63873afdd3b2bbf302a3fe58621f5853ba1d
    Signed-off-by: haochen <haochen at multicorewareinc.com>
    Signed-off-by: Wei Wei <weiwei at multicorewareinc.com>
    Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>

diff --git a/sc/qa/unit/data/xls/opencl/math/MROUND.xls b/sc/qa/unit/data/xls/opencl/math/MROUND.xls
new file mode 100644
index 0000000..5aeabf3
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/math/MROUND.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 293a6fe..53db504 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -279,6 +279,7 @@ public:
     void testStatisticalFormulaStDevPA();
     void testMathFormulaSEC();
     void testMathFormulaSECH();
+    void testMathFormulaMROUND();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -488,6 +489,7 @@ public:
     CPPUNIT_TEST(testStatisticalFormulaStDevPA);
     CPPUNIT_TEST(testMathFormulaSEC);
     CPPUNIT_TEST(testMathFormulaSECH);
+    CPPUNIT_TEST(testMathFormulaMROUND);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -5761,6 +5763,29 @@ void ScOpenclTest::testMathFormulaSECH()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//AMLOEXT-369
+void ScOpenclTest::testMathFormulaMROUND()
+{
+    if (!detectOpenCLDevice())
+        return;
+
+    ScDocShellRef xDocSh = loadDoc("opencl/math/MROUND.", XLS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/math/MROUND.", XLS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    for (SCROW i = 0; i <= 13; ++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 c658befebe5c9ca25a6d73006ec92e6d3859bf73
Author: mulei <mulei at multicorewareinc.com>
Date:   Mon Dec 16 12:04:47 2013 +0800

    GPU Calc: implemented MROUND
    
    AMLOEXT-369 FIX
    
    Change-Id: I694c7f342d27ae045db03f75896663a316cc8b1e
    Signed-off-by: haochen <haochen at multicorewareinc.com>
    Signed-off-by: Wei Wei <weiwei 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 c42dd49..aa34d76 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -2797,6 +2797,13 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                     mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],
                         new OpIsOdd));
                 }
+                else if ( !(pChild->GetExternal().compareTo(OUString(
+                     "com.sun.star.sheet.addin.Analysis.getMround"))))
+                {
+                    mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],
+                        new OpMROUND));
+                }
+                break;
                 break;
 
             default:
diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx
index e109b03..504f616 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -111,6 +111,76 @@ void OpSecH::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "    return pow(cosh(arg0),-1 );\n";
     ss << "}";
 }
+void OpMROUND::GenSlidingWindowFunction(std::stringstream &ss,
+        const std::string sSymName, SubArguments &vSubArguments)
+{
+    ss << "\ndouble " << sSymName;
+    ss << "_"<< BinFuncName() <<"(";
+    for (unsigned i = 0; i < vSubArguments.size(); i++)
+    {
+        if (i)
+            ss << ", ";
+        vSubArguments[i]->GenSlidingWindowDecl(ss);
+    }
+    ss<<") {\n";
+    ss<<"    double tmp = 0;\n";
+    ss<<"    int gid0 = get_global_id(0);\n";
+    ss<<"    double arg0=0;\n";
+    ss<<"    double arg1=0;\n";
+    ss <<"\n    ";
+    //while (i-- > 1)
+    for (size_t i = 0; i < vSubArguments.size(); i++)
+    {
+        FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
+        assert(pCur);
+        if (pCur->GetType() == formula::svSingleVectorRef)
+        {
+#ifdef  ISNAN
+            const formula::SingleVectorRefToken* pSVR =
+                dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
+            ss << "if (gid0 < " << pSVR->GetArrayLength() << "){\n";
+#else
+#endif
+        }
+        else if (pCur->GetType() == formula::svDouble)
+        {
+#ifdef  ISNAN
+            ss << "{\n";
+#endif
+        }
+        else
+        {
+#ifdef  ISNAN
+#endif
+        }
+#ifdef  ISNAN
+        if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
+        {
+            ss << "        tmp=";
+            ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss << ";\n";
+            ss << "        if (isNan(tmp))\n";
+            ss << "            arg"<<i<<"= 0;\n";
+            ss << "        else\n";
+            ss << "            arg"<<i<<"=tmp;\n";
+            ss << "    }\n";
+        }
+        else
+        {
+            ss<<"    arg"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss<<";\n";
+        }
+#else
+        ss<<"arg"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
+        ss<<";\n";
+#endif
+    }
+    ss<<"    if(arg1==0)\n";
+    ss<<"        return arg1;\n";
+    ss<<"    tmp=arg1 * round(arg0 * pow(arg1,-1));\n";
+    ss<<"    return tmp;\n";
+    ss<<"}";
+}
 void OpCosh::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 b1d95f6..c2dccb2 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -38,6 +38,16 @@ public:
 
     virtual std::string BinFuncName(void) const { return "SecH"; }
 };
+class OpMROUND: public Normal
+{
+public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+            const std::string sSymName, SubArguments &vSubArguments);
+
+    virtual std::string BinFuncName(void) const { return "MROUND"; }
+};
+
+
 class OpCsc: public Normal
 {
 public:
commit e8036abfc00a34d47f638437035b61bfabf81477
Author: mulei <mulei at multicorewareinc.com>
Date:   Mon Dec 16 11:58:09 2013 +0800

    GPU Calc: unit test cases for SECH
    
    Turn   NO_FALLBACK_TO_SWINTERP  on in formulagroupcl.cxx for test
    
    AMLOEXT-368 BUG
    
    Change-Id: Id0f42bb75da00791cc83ea660ffaae9843e76541
    Signed-off-by: haochen <haochen at multicorewareinc.com>
    Signed-off-by: Wei Wei <weiwei at multicorewareinc.com>
    Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>

diff --git a/sc/qa/unit/data/ods/opencl/math/sech.ods b/sc/qa/unit/data/ods/opencl/math/sech.ods
new file mode 100644
index 0000000..a50c2e9
Binary files /dev/null and b/sc/qa/unit/data/ods/opencl/math/sech.ods differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index b1dc898..293a6fe 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -278,6 +278,7 @@ public:
     void testStatisticalFormulaStDevA();
     void testStatisticalFormulaStDevPA();
     void testMathFormulaSEC();
+    void testMathFormulaSECH();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -486,6 +487,7 @@ public:
     CPPUNIT_TEST(testStatisticalFormulaStDevA);
     CPPUNIT_TEST(testStatisticalFormulaStDevPA);
     CPPUNIT_TEST(testMathFormulaSEC);
+    CPPUNIT_TEST(testMathFormulaSECH);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -5736,6 +5738,29 @@ void ScOpenclTest::testMathFormulaSEC()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//AMLOEXT-368
+void ScOpenclTest::testMathFormulaSECH()
+{
+    if (!detectOpenCLDevice())
+        return;
+
+    ScDocShellRef xDocSh = loadDoc("opencl/math/sech.", ODS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/math/sech.", ODS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    for (SCROW i = 0; i <= 15; ++i)
+    {
+        double fLibre = pDoc->GetValue(ScAddress(1,i,0));
+        double fExcel = pDocRes->GetValue(ScAddress(1,i,0));
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+    }
+    xDocSh->DoClose();
+    xDocShRes->DoClose();
+}
 ScOpenclTest::ScOpenclTest()
       : ScBootstrapFixture( "/sc/qa/unit/data" )
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 4db7144..a7b95e5 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1503,6 +1503,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocStDevA:
             case ocStDevPA:
             case ocSecant:
+            case ocSecantHyp:
             // Don't change the state.
             break;
             default:
commit c46a3b6c78e56b64f1c36a257143abded69af370
Author: mulei <mulei at multicorewareinc.com>
Date:   Mon Dec 16 11:58:41 2013 +0800

    GPU Calc: implemented SECH
    
    AMLOEXT-368 FIX
    
    Change-Id: I8c0bece5ec12cd6def88431cf1d075d542369ca4
    Signed-off-by: haochen <haochen at multicorewareinc.com>
    Signed-off-by: Wei Wei <weiwei 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 9866168..c42dd49 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -2581,6 +2581,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 mvSubArguments.push_back(SoPHelper(ts,
                          ft->Children[i], new OpSec));
                 break;
+            case ocSecantHyp:
+                mvSubArguments.push_back(SoPHelper(ts,
+                         ft->Children[i], new OpSecH));
+                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 3a68fc6..e109b03 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -84,7 +84,33 @@ void OpCosh::BinInlineFun(std::set<std::string>& decls,
     decls.insert(local_coshDecl);
     funs.insert(local_cosh);
 }
-
+void OpSecH::GenSlidingWindowFunction(std::stringstream &ss,
+            const std::string sSymName, SubArguments &vSubArguments)
+{
+    FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
+    const formula::SingleVectorRefToken*tmpCurDVR= dynamic_cast<const
+          formula::SingleVectorRefToken *>(tmpCur);
+    ss << "\ndouble " << sSymName;
+    ss << "_"<< BinFuncName() <<"(";
+    for (unsigned i = 0; i < vSubArguments.size(); i++)
+    {
+        if (i)
+            ss << ",";
+        vSubArguments[i]->GenSlidingWindowDecl(ss);
+    }
+    ss << ") {\n";
+    ss <<"    int gid0=get_global_id(0);\n";
+    ss <<"    double arg0 = " << vSubArguments[0]->GenSlidingWindowDeclRef();
+    ss <<";\n";
+#ifdef ISNAN
+    ss<<"    if(isNan(arg0)||(gid0>=";
+    ss<<tmpCurDVR->GetArrayLength();
+    ss<<"))\n";
+    ss<<"        arg0 = 0;\n";
+#endif
+    ss << "    return pow(cosh(arg0),-1 );\n";
+    ss << "}";
+}
 void OpCosh::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 057df65..b1d95f6 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -30,6 +30,14 @@ public:
 
     virtual std::string BinFuncName(void) const { return "Sec"; }
 };
+class OpSecH: public Normal
+{
+public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+            const std::string sSymName, SubArguments &vSubArguments);
+
+    virtual std::string BinFuncName(void) const { return "SecH"; }
+};
 class OpCsc: public Normal
 {
 public:
commit bfef2c95524bdb7ad8f6c6271e8858acd4585e25
Author: mulei <mulei at multicorewareinc.com>
Date:   Mon Dec 16 11:54:26 2013 +0800

    GPU Calc: unit test cases for SEC
    
    Turn   NO_FALLBACK_TO_SWINTERP  on in formulagroupcl.cxx for test
    
    AMLOEXT-367 BUG
    
    Change-Id: I9e6d49e5b2f73bca3a3920c4e60c24576d724f8c
    Signed-off-by: haochen <haochen at multicorewareinc.com>
    Signed-off-by: Wei Wei <weiwei at multicorewareinc.com>
    Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>

diff --git a/sc/qa/unit/data/ods/opencl/math/sec.ods b/sc/qa/unit/data/ods/opencl/math/sec.ods
new file mode 100644
index 0000000..1c5250d
Binary files /dev/null and b/sc/qa/unit/data/ods/opencl/math/sec.ods differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index e536dc0..b1dc898 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -277,6 +277,7 @@ public:
     void testStatisticalFormulaVarPA();
     void testStatisticalFormulaStDevA();
     void testStatisticalFormulaStDevPA();
+    void testMathFormulaSEC();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -484,6 +485,7 @@ public:
     CPPUNIT_TEST(testStatisticalFormulaVarPA);
     CPPUNIT_TEST(testStatisticalFormulaStDevA);
     CPPUNIT_TEST(testStatisticalFormulaStDevPA);
+    CPPUNIT_TEST(testMathFormulaSEC);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -5711,6 +5713,29 @@ void ScOpenclTest::testMathFormulaFact()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//AMLOEXT-367
+void ScOpenclTest::testMathFormulaSEC()
+{
+    if (!detectOpenCLDevice())
+        return;
+
+    ScDocShellRef xDocSh = loadDoc("opencl/math/sec.", ODS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/math/sec.", ODS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    for (SCROW i = 0; i <= 15; ++i)
+    {
+        double fLibre = pDoc->GetValue(ScAddress(1,i,0));
+        double fExcel = pDocRes->GetValue(ScAddress(1,i,0));
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+    }
+    xDocSh->DoClose();
+    xDocShRes->DoClose();
+}
 ScOpenclTest::ScOpenclTest()
       : ScBootstrapFixture( "/sc/qa/unit/data" )
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 347f696..4db7144 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1502,6 +1502,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocVarPA:
             case ocStDevA:
             case ocStDevPA:
+            case ocSecant:
             // Don't change the state.
             break;
             default:
commit 2d4f27922f79dac376413031ca35b57b18522ce7
Author: mulei <mulei at multicorewareinc.com>
Date:   Mon Dec 16 11:55:15 2013 +0800

    GPU Calc: implemented SEC
    
    AMLOEXT-367 FIX
    
    Change-Id: I020821719a43bdf20f10a79f9c11fa721b248254
    Signed-off-by: haochen <haochen at multicorewareinc.com>
    Signed-off-by: Wei Wei <weiwei 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 c9b9229..9866168 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -2577,6 +2577,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 mvSubArguments.push_back(SoPHelper(ts,
                          ft->Children[i], new OpStDevPA));
                  break;
+            case ocSecant:
+                mvSubArguments.push_back(SoPHelper(ts,
+                         ft->Children[i], new OpSec));
+                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 1db438c..3a68fc6 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -51,7 +51,33 @@ void OpCos::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "return tmp;\n";
     ss << "}";
 }
-
+void OpSec::GenSlidingWindowFunction(std::stringstream &ss,
+            const std::string sSymName, SubArguments &vSubArguments)
+{
+    FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
+    const formula::SingleVectorRefToken*tmpCurDVR= dynamic_cast<const
+          formula::SingleVectorRefToken *>(tmpCur);
+    ss << "\ndouble " << sSymName;
+    ss << "_"<< BinFuncName() <<"(";
+    for (unsigned i = 0; i < vSubArguments.size(); i++)
+    {
+        if (i)
+            ss << ",";
+        vSubArguments[i]->GenSlidingWindowDecl(ss);
+    }
+    ss << ") {\n";
+    ss <<"    int gid0=get_global_id(0);\n";
+    ss <<"    double arg0 = " << vSubArguments[0]->GenSlidingWindowDeclRef();
+    ss <<";\n";
+#ifdef ISNAN
+    ss<<"    if(isNan(arg0)||(gid0>=";
+    ss<<tmpCurDVR->GetArrayLength();
+    ss<<"))\n";
+    ss<<"        arg0 = 0;\n";
+#endif
+    ss << "    return pow(cos(arg0),-1 );\n";
+    ss << "}";
+}
 void OpCosh::BinInlineFun(std::set<std::string>& decls,
     std::set<std::string>& funs)
 {
diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx
index ffdb74c..057df65 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -22,7 +22,14 @@ public:
 
     virtual std::string BinFuncName(void) const { return "Cos"; }
 };
+class OpSec: public Normal
+{
+public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+            const std::string sSymName, SubArguments &vSubArguments);
 
+    virtual std::string BinFuncName(void) const { return "Sec"; }
+};
 class OpCsc: public Normal
 {
 public:
commit bda58c33afe9a9f6ca4f8b27bff44ba2c22da395
Author: shiming zhang <shiming at multicorewareinc.com>
Date:   Mon Dec 16 11:47:11 2013 +0800

    GPU Calc: unit test cases for STDEVPA
    
    Turn  NO_FALLBACK_TO_SWINTERP on in  formulagroupcl.cxx for test
    
    AMLOEXT-221 BUG
    
    Change-Id: I6cfe613497a2fee5f271208b6b82db9ea753ff97
    Signed-off-by: haochen <haochen at multicorewareinc.com>
    Signed-off-by: Wei Wei <weiwei at multicorewareinc.com>
    Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>

diff --git a/sc/qa/unit/data/xls/opencl/statistical/StDevPA.xls b/sc/qa/unit/data/xls/opencl/statistical/StDevPA.xls
new file mode 100644
index 0000000..05b267f
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/statistical/StDevPA.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 58c40e1..e536dc0 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -276,6 +276,7 @@ public:
     void testStatisticalFormulaVarA();
     void testStatisticalFormulaVarPA();
     void testStatisticalFormulaStDevA();
+    void testStatisticalFormulaStDevPA();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -482,6 +483,7 @@ public:
     CPPUNIT_TEST(testStatisticalFormulaVarA);
     CPPUNIT_TEST(testStatisticalFormulaVarPA);
     CPPUNIT_TEST(testStatisticalFormulaStDevA);
+    CPPUNIT_TEST(testStatisticalFormulaStDevPA);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -4975,7 +4977,6 @@ void ScOpenclTest::testMathFormulaAverageIf()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
-
 //[AMLOEXT-216]
 void ScOpenclTest::testStatisticalFormulaAverageA()
 {
@@ -4998,7 +4999,6 @@ void ScOpenclTest::testStatisticalFormulaAverageA()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
-
 //[AMLOEXT-217]
 void ScOpenclTest:: testLogicalFormulaAnd()
 {
@@ -5027,7 +5027,6 @@ void ScOpenclTest:: testLogicalFormulaAnd()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
-
 //[AMLOEXT-218]
 void ScOpenclTest::testStatisticalFormulaVarA()
 {
@@ -5053,7 +5052,6 @@ void ScOpenclTest::testStatisticalFormulaVarA()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
-
 //[AMLOEXT-219]
 void ScOpenclTest::testStatisticalFormulaVarPA()
 {
@@ -5079,7 +5077,6 @@ void ScOpenclTest::testStatisticalFormulaVarPA()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
-
 //[AMLOEXT-220]
 void ScOpenclTest::testStatisticalFormulaStDevA()
 {
@@ -5105,7 +5102,31 @@ void ScOpenclTest::testStatisticalFormulaStDevA()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-221]
+void ScOpenclTest::testStatisticalFormulaStDevPA()
+{
+    if (!detectOpenCLDevice())
+        return;
+
+    ScDocShellRef xDocSh = loadDoc("opencl/statistical/StDevPA.", XLS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
 
+    ScDocShellRef xDocShRes = loadDoc("opencl/statistical/StDevPA.", 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-245]
 void ScOpenclTest::testMathFormulaSumProduct2()
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 9505f46..347f696 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1501,6 +1501,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocVarA:
             case ocVarPA:
             case ocStDevA:
+            case ocStDevPA:
             // Don't change the state.
             break;
             default:
commit 18e64e70a35b55fc37bacdff935f70bc5e851660
Author: shiming zhang <shiming at multicorewareinc.com>
Date:   Mon Dec 16 11:47:42 2013 +0800

    GPU Calc: implemented STDEVPA
    
    AMLOEXT-221 FIX
    
    Change-Id: Ifc17fcccdae69e6a75c49cbfdffdec7d00554d3c
    Signed-off-by: haochen <haochen at multicorewareinc.com>
    Signed-off-by: Wei Wei <weiwei 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 2cad226..c9b9229 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -2573,6 +2573,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 mvSubArguments.push_back(SoPHelper(ts,
                          ft->Children[i], new OpStDevA));
                  break;
+            case ocStDevPA:
+                mvSubArguments.push_back(SoPHelper(ts,
+                         ft->Children[i], new OpStDevPA));
+                 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 6061d88..43dd939 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -10826,6 +10826,428 @@ void OpStDevA::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "        return sqrt(vSum * pow(fCount - 1.0,-1.0));\n";
     ss << "}\n";
 }
+void OpStDevPA::GenSlidingWindowFunction(std::stringstream &ss,
+            const std::string sSymName, SubArguments &vSubArguments)
+{
+    int isMixedDV = 0;
+    int isMixedSV = 0;
+    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);
+                if(pDVR->GetArrays()[0].mpNumericArray
+                    && pDVR->GetArrays()[0].mpStringArray)
+                    isMixedDV = svDoubleVectorRefDoubleString;
+                else if(pDVR->GetArrays()[0].mpNumericArray)
+                    isMixedDV = svDoubleVectorRefDouble;
+                else if(pDVR->GetArrays()[0].mpStringArray)
+                    isMixedDV = svDoubleVectorRefString;
+                else
+                    isMixedDV = svDoubleVectorRefNULL;
+
+                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 < " << pDVR->GetArrayLength() << "; i++)\n";
+                    ss << "    {\n";
+#else
+                    ss << "0; i < " << pDVR->GetArrayLength() << "; i++)\n";
+                    ss << "    {\n";
+#endif
+                }
+
+                if(isMixedDV == svDoubleVectorRefDoubleString)
+                {
+                    ss << "        arg = ";
+                    ss << vSubArguments[i]->GenDoubleSlidingWindowDeclRef();
+                    ss << ";\n";
+#ifdef  ISNAN
+                    ss << "        if (isNan(arg) && ";
+                    ss << vSubArguments[i]->GenStringSlidingWindowDeclRef();
+                    ss << " == 0)\n";
+                    ss << "            continue;\n";
+                    ss << "        if(isNan(arg) && ";
+                    ss << vSubArguments[i]->GenStringSlidingWindowDeclRef();
+                    ss << " != 0)\n";
+                    ss << "        {\n";
+                    ss << "            fCount = fCount + 1.0;\n";
+                    ss << "            continue;\n";
+                    ss << "        }\n";
+#endif
+                    ss << "        fSum += arg;\n";
+                    ss << "        fCount = fCount + 1.0;\n";
+                    ss << "    }\n";
+                }
+                else if(isMixedDV == svDoubleVectorRefDouble)
+                {
+                    ss << "        arg = ";
+                    ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+                    ss << ";\n";
+#ifdef  ISNAN
+                    ss << "        if (isNan(arg))\n";
+                    ss << "            continue;\n";
+#endif
+                    ss << "        fSum += arg;\n";
+                    ss << "        fCount = fCount + 1.0;\n";
+                    ss << "    }\n";
+                }
+                else if(isMixedDV == svDoubleVectorRefString)
+                {
+                    ss << "        if (";
+                    ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+                    ss << " == 0)\n";
+                    ss << "            continue;\n";
+                    ss << "        fCount = fCount + 1.0;\n";
+                    ss << "    }\n";
+                }
+                else
+                {
+                    ss << "        continue;\n";
+                    ss << "    }\n";
+                }
+
+            }
+            else if (pCur->GetType() == formula::svSingleVectorRef)
+            {
+                const formula::SingleVectorRefToken* pSVR =
+                    dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
+                assert(pSVR);
+                if(pSVR->GetArray().mpNumericArray
+                    && pSVR->GetArray().mpStringArray)
+                    isMixedSV = svSingleVectorRefDoubleString;
+                else if(pSVR->GetArray().mpNumericArray)
+                    isMixedSV = svSingleVectorRefDouble;
+                else if(pSVR->GetArray().mpStringArray)
+                    isMixedSV = svSingleVectorRefString;
+                else
+                    isMixedSV = svSingleVectorRefNULL;
+
+                if(isMixedSV == svSingleVectorRefDoubleString)
+                {
+#ifdef  ISNAN
+                    ss << "    if (gid0 < " << pSVR->GetArrayLength() << ")\n";
+                    ss << "    {\n";
+#endif
+                    ss << "        arg = ";
+                    ss << vSubArguments[i]->GenDoubleSlidingWindowDeclRef();
+                    ss << ";\n";
+#ifdef  ISNAN
+                    ss << "        if (!isNan(arg))\n";
+                    ss << "        {\n";
+#endif
+                    ss << "            fSum += arg;\n";
+                    ss << "            fCount = fCount + 1.0;\n";
+#ifdef ISNAN
+                    ss << "        }\n";
+                    ss << "        if (isNan(arg) && ";
+                    ss << vSubArguments[i]->GenStringSlidingWindowDeclRef();
+                    ss << " != 0)\n";
+                    ss << "            fCount = fCount + 1.0;\n";
+                    ss << "    }\n";
+#endif
+                }
+                else if(isMixedSV == svSingleVectorRefDouble)
+                {
+#ifdef  ISNAN
+                    ss << "    if (gid0 < " << pSVR->GetArrayLength() << ")\n";
+                    ss << "    {\n";
+#endif
+                    ss << "        arg = ";
+                    ss << vSubArguments[i]->GenSlidingWindowDeclRef() << ";\n";
+#ifdef ISNAN
+                    ss << "        if (!isNan(arg))\n";
+                    ss << "        {\n";
+#endif
+                    ss << "            fSum += arg;\n";
+                    ss << "            fCount += 1.0;\n";
+#ifdef ISNAN
+                    ss << "        }\n";
+                    ss << "    }\n";
+#endif
+                }
+                else if(isMixedSV == svSingleVectorRefString)
+                {
+
+                    ss << "    if (gid0 < " << pSVR->GetArrayLength() << ")\n";
+                    ss << "    {\n";
+                    ss << "        if (";
+                    ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+                    ss << " != 0)\n";
+                    ss << "            fCount = fCount + 1.0;\n";
+                    ss << "    }\n";
+                }
+                else
+                {
+                    ss << "    arg =0.0;\n";
+                }
+            }
+            else
+            {
+                ss << "    arg = " << pCur->GetDouble() << ";\n";
+                ss << "    fSum += arg;\n";
+                ss << "    fCount = fCount + 1.0;\n";
+            }
+        }
+        else
+        {
+            ss << "    arg = ";
+            ss << vSubArguments[i]->GenSlidingWindowDeclRef() << ";\n";
+            ss << "    fSum += arg;\n";
+            ss << "    fCount = fCount + 1.0;\n";
+        }
+        if (i == 0)
+        {
+            ss << "    fMean = fSum * pow(fCount,-1.0);\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 < " << pDVR->GetArrayLength() << "; i++)\n";
+                    ss << "    {\n";
+#else
+                    ss << "0; i < " << pDVR->GetArrayLength() << "; i++)\n";
+                    ss << "    {\n";
+#endif
+                }
+                if(isMixedDV == svDoubleVectorRefDoubleString)
+                {
+                    ss << "        arg = ";
+                    ss << vSubArguments[i]->GenDoubleSlidingWindowDeclRef();
+                    ss << ";\n";
+#ifdef  ISNAN
+                    ss << "        if (isNan(arg) && ";
+                    ss << vSubArguments[i]->GenStringSlidingWindowDeclRef();
+                    ss << " == 0)\n";
+                    ss << "            continue;\n";
+                    ss << "        if(isNan(arg) && ";
+                    ss << vSubArguments[i]->GenStringSlidingWindowDeclRef();
+                    ss << " != 0)\n";
+                    ss << "            arg = 0.0;\n";
+#endif
+                    ss << "        vSum += (arg - fMean) * (arg - fMean);\n";
+                    ss << "    }\n";
+
+                }
+                else if(isMixedDV == svDoubleVectorRefDouble)
+                {
+                    ss << "        arg = ";
+                    ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+                    ss << ";\n";
+#ifdef  ISNAN
+                    ss << "        if (isNan(arg))\n";
+                    ss << "            continue;\n";
+#endif
+                    ss << "        vSum += (arg - fMean) * (arg - fMean);\n";
+                    ss << "    }\n";
+
+                }
+                else if(isMixedDV == svDoubleVectorRefString)
+                {
+                    ss << "        if (";
+                    ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+                    ss << " == 0)\n";
+                    ss << "            continue;\n";
+                    ss << "        arg = 0.0;\n";
+                    ss << "        vSum += (arg - fMean) * (arg - fMean);\n";
+                    ss << "    }\n";
+                }
+                else
+                {
+                    ss << "        continue;\n";
+                    ss << "    }\n";
+                }
+            }
+            else if (pCur->GetType() == formula::svSingleVectorRef)
+            {
+                const formula::SingleVectorRefToken* pSVR =
+                    dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
+                assert(pSVR);
+                if(isMixedSV == svSingleVectorRefDoubleString)
+                {
+#ifdef  ISNAN
+                    ss << "    if (gid0 < " << pSVR->GetArrayLength() << ")\n";
+                    ss << "    {\n";
+#endif
+                    ss << "        arg = ";
+                    ss << vSubArguments[i]->GenDoubleSlidingWindowDeclRef();
+                    ss << ";\n";
+#ifdef  ISNAN
+                    ss << "        if (!isNan(arg))\n";
+#endif
+                    ss << "            vSum += (arg - fMean)*(arg - fMean);\n";
+#ifdef ISNAN
+                    ss << "        if (isNan(arg) && ";
+                    ss << vSubArguments[i]->GenStringSlidingWindowDeclRef();
+                    ss << " != 0)\n";
+                    ss << "        {\n";
+                    ss << "            arg = 0.0;\n";
+                    ss << "            vSum += (arg - fMean)*(arg - fMean);\n";
+                    ss << "        }\n";
+                    ss << "    }\n";
+#endif
+                }
+                else if(isMixedSV == svSingleVectorRefDouble)
+                {
+#ifdef  ISNAN
+                    ss << "    if (gid0 < " << pSVR->GetArrayLength() << ")\n";
+                   ss << "    {\n";
+#endif
+                    ss << "        arg = ";
+                    ss << vSubArguments[i]->GenSlidingWindowDeclRef() << ";\n";
+#ifdef  ISNAN
+                    ss << "        if (!isNan(arg))\n";
+                    ss << "        {\n";
+#endif

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list