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

hongyu zhong hongyu at multicorewareinc.com
Mon Dec 23 14:51:55 PST 2013


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

New commits:
commit 2bb1a845a25ca9a39c96f37995453844461aed4e
Author: hongyu zhong <hongyu at multicorewareinc.com>
Date:   Fri Dec 20 14:41:47 2013 +0800

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

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

    GPU Calc: Optimized ASIN
    
    AMLOEXT-269
    
    Change-Id: I10d33b50f743630ed91daa743017e431754e5659
    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 85fdfa1..f0ed0b1 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1325,6 +1325,12 @@ void OpArcCotHyp::GenSlidingWindowFunction(std::stringstream &ss,
      ss << "    return 0.5 * log(1 + 2 * pown(arg0 - 1.0, -1));\n";
      ss << "}";
 }
+void OpArcSin::BinInlineFun(std::set<std::string>& decls,
+    std::set<std::string>& funs)
+{
+    decls.insert(atan2Decl);
+    funs.insert(atan2Content);
+}
 void OpArcSin::GenSlidingWindowFunction(std::stringstream &ss,
     const std::string sSymName, SubArguments &vSubArguments)
 {
@@ -1349,7 +1355,7 @@ void OpArcSin::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "    else \n    ";
 #endif
     ss << "    tmp = " << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
-    ss << "    return asin(tmp);\n";
+    ss << "    return arctan2(tmp, sqrt(1.0 - pow(tmp, 2)));\n";
     ss << "}";
 }
 void OpArcSinHyp::GenSlidingWindowFunction(std::stringstream &ss,
diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx
index a174bef..e10dfa1 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -153,6 +153,7 @@ public:
         const std::string sSymName, SubArguments &vSubArguments);
     virtual std::string GetBottom(void) { return "0.0"; }
     virtual std::string BinFuncName(void) const { return "ScASin"; }
+    virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>&);
 };
 class OpArcSinHyp:public Normal{
 public:
commit f48749354f018ef41b135bad0d433d94778accd5
Author: yangzhang <yangzhang at multicorewareinc.com>
Date:   Fri Dec 20 13:55:26 2013 +0800

    GPU Calc: Optimized ATAN2
    
    AMLOEXT-349
    
    Change-Id: Ifd9532d7b73afee1a0d6eb8f2d4522e0356006f5
    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 3958781..85fdfa1 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1396,6 +1396,12 @@ void OpArcSinHyp::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "    return  log( tmp + pow((pown(tmp, 2) + 1.0), 0.5));\n";
     ss << "}";
 }
+void OpArcTan2::BinInlineFun(std::set<std::string>& decls,
+    std::set<std::string>& funs)
+{
+    decls.insert(atan2Decl);
+    funs.insert(atan2Content);
+}
 void OpArcTan2::GenSlidingWindowFunction(std::stringstream &ss,
     const std::string sSymName, SubArguments &vSubArguments)
 {
@@ -1432,7 +1438,7 @@ void OpArcTan2::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "    else \n    ";
 #endif
     ss << "    y_num = "<< vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
-    ss << "    return atan2(y_num, x_num);\n";
+    ss << "    return arctan2(y_num, x_num);\n";
     ss << "}";
 }
 void OpArcTan::GenSlidingWindowFunction(std::stringstream &ss,
diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx
index b0d7980..a174bef 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -175,6 +175,7 @@ public:
         const std::string sSymName, SubArguments &vSubArguments);
     virtual std::string GetBottom(void) { return "0.0"; }
     virtual std::string BinFuncName(void) const { return "ScATan2"; }
+    virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>&);
 };
 class OpArcTan:public Normal{
 public:
diff --git a/sc/source/core/opencl/opinlinefun_math.hxx b/sc/source/core/opencl/opinlinefun_math.hxx
index b641c52..a813091 100644
--- a/sc/source/core/opencl/opinlinefun_math.hxx
+++ b/sc/source/core/opencl/opinlinefun_math.hxx
@@ -56,6 +56,35 @@ std::string local_cosh =
 "    double nVal = (exp(n) + exp(-n)) / 2;\n"
 "    return nVal;\n"
 "}\n";
+std::string atan2Decl = "double arctan2(double y, double x);\n";
+std::string atan2Content =
+"double arctan2(double y, double x)\n"
+"{\n"
+"    if(y==0.0)\n"
+"        return 0.0;\n"
+"    double a,num,den,tmpPi;\n"
+"    int flag;\n"
+"    tmpPi = 0;\n"
+"    if (fabs(x) >= fabs(y))\n"
+"    {\n"
+"        num = y;\n"
+"        den = x;\n"
+"        flag = 1;\n"
+"        if (x < 0.0)\n"
+"            tmpPi = M_PI;\n"
+"    }\n"
+"    if(fabs(x) < fabs(y))\n"
+"    {\n"
+"        num = x;\n"
+"        den = y;\n"
+"        flag = -1;\n"
+"        tmpPi = M_PI_2;\n"
+"    }\n"
+"    a = atan(num/den);\n"
+"    a = flag==1?a:-a;\n"
+"    a = a + (y >= 0.0 ? tmpPi : -tmpPi);\n"
+"    return a;\n"
+"}\n";
 
 
 #endif //SC_OPENCL_OPINLINFUN_MATH
commit bc7c98cf20c1b39edf6d832e3fb09e550df2e485
Author: yiming ju <yiming at multicorewareinc.com>
Date:   Fri Dec 20 13:28:22 2013 +0800

    GPU Calc: Fix Bug of TBILLYIELD&TBILLEQ
    
    AMLOEXT-376
    
    Change-Id: I067819191f5926cef31ab50f1ad46d64a1e58a5c
    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_financial.cxx b/sc/source/core/opencl/op_financial.cxx
index 13c3e11..49a383d 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -1685,11 +1685,11 @@ void OpEffective::GenSlidingWindowFunction(std::stringstream& ss,
     std::set<std::string>& funs)
 {
     decls.insert(GetDiffDate360_Decl);decls.insert(GetDiffDate360Decl);
-    decls.insert(DateToDaysDecl);decls.insert(DaysToDateDecl);
+    decls.insert(DateToDaysDecl);decls.insert(DaysToDate_LocalBarrierDecl);
     decls.insert(DaysInMonthDecl);decls.insert(GetNullDateDecl);
     decls.insert(IsLeapYearDecl);
     funs.insert(GetDiffDate360_);funs.insert(GetDiffDate360);
-    funs.insert(DateToDays);funs.insert(DaysToDate);
+    funs.insert(DateToDays);funs.insert(DaysToDate_LocalBarrier);
     funs.insert(DaysInMonth);funs.insert(GetNullDate);
     funs.insert(IsLeapYear);
 }
@@ -4845,11 +4845,11 @@ void RATE::GenSlidingWindowFunction(
     std::set<std::string>& funs)
 {
     decls.insert(GetDiffDate360Decl);decls.insert(IsLeapYearDecl);
-    decls.insert(DateToDaysDecl);decls.insert(DaysToDateDecl);
+    decls.insert(DateToDaysDecl);decls.insert(DaysToDate_LocalBarrierDecl);
     decls.insert(DaysInMonthDecl);decls.insert(GetNullDateDecl);
     decls.insert(GetDiffDate360_Decl);
     funs.insert(GetDiffDate360);funs.insert(DateToDays);
-    funs.insert(DaysToDate);funs.insert(IsLeapYear);
+    funs.insert(DaysToDate_LocalBarrier);funs.insert(IsLeapYear);
     funs.insert(DaysInMonth);funs.insert(GetNullDate);
     funs.insert(GetDiffDate360_);
 
@@ -4930,14 +4930,14 @@ void OpTbillyield::GenSlidingWindowFunction(
     ss<<"tmp002 = ";
     ss << vSubArguments[2]->GenSlidingWindowDeclRef();
     ss<<";\n\t";
-    ss <<"int nDiff=GetDiffDate360(GetNullDate(),tmp000,tmp001,true);\n";
-    ss <<"nDiff++;\n";
-    ss <<"tmp=100.0;\n";
-    ss <<"tmp /= tmp002;\n";
-    ss <<"tmp-=1.0;\n";
-    ss <<"tmp= tmp/( nDiff );\n";
-    ss <<"tmp *= 360.0;\n";
-    ss <<"return tmp;\n";
+    ss <<"    int nDiff=GetDiffDate360(GetNullDate(),tmp000,tmp001,true);\n";
+    ss <<"    nDiff++;\n";
+    ss <<"    tmp=100.0;\n";
+    ss <<"    tmp = tmp *pow( tmp002,-1);\n";
+    ss <<"    tmp = tmp - 1.0;\n";
+    ss <<"    tmp = tmp * pow( nDiff,-1.0 );\n";
+    ss <<"    tmp = tmp * 360.0;\n";
+    ss <<"    return tmp;\n";
     ss << "}\n";
 }
 void OpDDB::GenSlidingWindowFunction(std::stringstream& ss,
diff --git a/sc/source/core/opencl/opinlinefun_finacial.cxx b/sc/source/core/opencl/opinlinefun_finacial.cxx
index 2b81df2..1cb2697 100644
--- a/sc/source/core/opencl/opinlinefun_finacial.cxx
+++ b/sc/source/core/opencl/opinlinefun_finacial.cxx
@@ -1654,6 +1654,52 @@ std::string DaysToDate_new =
 "    }\n"
 "}\n";
 
+std::string DaysToDate_LocalBarrierDecl =
+"void DaysToDate( int nDays, int *rDay, int* rMonth, int* rYear );\n";
+
+std::string DaysToDate_LocalBarrier =
+"void DaysToDate( int nDays, int *rDay, int* rMonth, int* rYear )\n"
+"{\n"
+"    int   nTempDays;\n"
+"    int   i = 0;\n"
+"    bool    bCalc;\n"
+"    do\n"
+"    {\n"
+"        nTempDays = nDays;\n"
+"        *rYear = (int)((nTempDays / 365) - i);\n"
+"        nTempDays -= ((int) *rYear -1) * 365;\n"
+"        nTempDays -= ((*rYear -1) / 4) - ((*rYear -1) / 100) + ((*rYear -1)"
+" / 400);\n"
+"        bCalc = false;\n"
+"        if ( nTempDays < 1 )\n"
+"        {\n"
+"            i++;\n"
+"            bCalc = true;\n"
+"        }\n"
+"        else\n"
+"        {\n"
+"            if ( nTempDays > 365 )\n"
+"            {\n"
+"                if ( (nTempDays != 366) || !IsLeapYear( *rYear ) )\n"
+"                {\n"
+"                    i--;\n"
+"                    bCalc = true;\n"
+"                }\n"
+"            }\n"
+"        }\n"
+"    }\n"
+"    while ( bCalc );\n"
+"    barrier(CLK_LOCAL_MEM_FENCE);\n"
+"    if(nTempDays != 0){\n"
+"        for (*rMonth = 1; (int)nTempDays > DaysInMonth( *rMonth, *rYear );"
+" *rMonth += 1)\n"
+"        {\n"
+"            nTempDays -= DaysInMonth( *rMonth, *rYear ); \n"
+"        }\n"
+"        *rDay = (int)nTempDays;\n"
+"    }\n"
+"}\n";
+
 std::string GetYearDiff_newDecl=
 "double GetYearDiff_new( int nNullDate, int nStartDate, int nEndDate,"
 "int nMode);\n";
commit 7eafa6f237005310da6ade542373e1e77e492c1f
Author: minwang <min at multicorewareinc.com>
Date:   Fri Dec 20 13:17:07 2013 +0800

    GPU Calc: Optimized DDB
    
    AMLOEXT-279
    
    Change-Id: I6d4d9f3fc67aeeb32b571998ef9ddeba66184449
    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_financial.cxx b/sc/source/core/opencl/op_financial.cxx
index 5c6da78..13c3e11 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -4955,81 +4955,83 @@ void OpDDB::GenSlidingWindowFunction(std::stringstream& ss,
     ss << "    int gid0 = get_global_id(0);\n";
     ss << "    double tmp = 0;\n";
     ss << "    double fWert,fRest,fDauer,fPeriode,fFaktor;\n";
-    ss << "    double fGda, fZins, fAlterWert, fNeuerWert;\n";
+    ss << "    double fZins, fAlterWert, fNeuerWert;\n";
+
 #ifdef ISNAN
     FormulaToken* tmpCur0 = vSubArguments[0]->GetFormulaToken();
-    const formula::SingleVectorRefToken*tmpCurDVR0= dynamic_cast<const
-    formula::SingleVectorRefToken *>(tmpCur0);
     FormulaToken* tmpCur1 = vSubArguments[1]->GetFormulaToken();
-    const formula::SingleVectorRefToken*tmpCurDVR1= dynamic_cast<const
-    formula::SingleVectorRefToken *>(tmpCur1);
     FormulaToken* tmpCur2 = vSubArguments[2]->GetFormulaToken();
-    const formula::SingleVectorRefToken*tmpCurDVR2= dynamic_cast<const
-    formula::SingleVectorRefToken *>(tmpCur2);
     FormulaToken* tmpCur3 = vSubArguments[3]->GetFormulaToken();
-    const formula::SingleVectorRefToken*tmpCurDVR3= dynamic_cast<const
-    formula::SingleVectorRefToken *>(tmpCur3);
     FormulaToken* tmpCur4 = vSubArguments[4]->GetFormulaToken();
-    const formula::SingleVectorRefToken*tmpCurDVR4= dynamic_cast<const
-    formula::SingleVectorRefToken *>(tmpCur4);
-    ss<< "    int buffer_wert_len = ";
-    ss<< tmpCurDVR0->GetArrayLength();
-    ss << ";\n";
-    ss<< "    int buffer_rest_len = ";
-    ss<< tmpCurDVR1->GetArrayLength();
-    ss << ";\n";
-    ss<< "    int buffer_dauer_len = ";
-    ss<< tmpCurDVR2->GetArrayLength();
-    ss << ";\n";
-    ss<< "    int buffer_periode_len = ";
-    ss<< tmpCurDVR3->GetArrayLength();
-    ss << ";\n";
-    ss<< "    int buffer_factor_len = ";
-    ss<< tmpCurDVR4->GetArrayLength();
-    ss << ";\n";
 #endif
 #ifdef ISNAN
-    ss <<"    if(gid0 >= buffer_wert_len || isNan(";
-    ss <<vSubArguments[0]->GenSlidingWindowDeclRef();
-    ss <<"))\n";
-    ss <<"        fWert = 0;\n    else\n";
+    if(tmpCur0->GetType() == formula::svSingleVectorRef)
+    {
+        const formula::SingleVectorRefToken*tmpCurDVR0= dynamic_cast<const
+        formula::SingleVectorRefToken *>(tmpCur0);
+        ss <<"    if(gid0 >= "<<tmpCurDVR0->GetArrayLength()<<" || isNan(";
+        ss <<vSubArguments[0]->GenSlidingWindowDeclRef();
+        ss <<"))\n";
+        ss <<"        fWert = 0;\n    else\n";
+    }
 #endif
     ss <<"        fWert = "<<vSubArguments[0]->GenSlidingWindowDeclRef();
     ss <<";\n";
 #ifdef ISNAN
-    ss <<"    if(gid0 >= buffer_rest_len || isNan(";
-    ss <<vSubArguments[1]->GenSlidingWindowDeclRef();
-    ss <<"))\n";
-    ss <<"        fRest = 0;\n    else\n";
+    if(tmpCur1->GetType() == formula::svSingleVectorRef)
+    {
+        const formula::SingleVectorRefToken*tmpCurDVR1= dynamic_cast<const
+        formula::SingleVectorRefToken *>(tmpCur1);
+        ss <<"    if(gid0 >= "<<tmpCurDVR1->GetArrayLength()<<" || isNan(";
+        ss <<vSubArguments[1]->GenSlidingWindowDeclRef();
+        ss <<"))\n";
+        ss <<"        fRest = 0;\n    else\n";
+    }
 #endif
     ss <<"        fRest = ";
     ss <<vSubArguments[1]->GenSlidingWindowDeclRef();
     ss <<";\n";
 #ifdef ISNAN
-    ss <<"    if(gid0 >= buffer_dauer_len || isNan(";
-    ss <<vSubArguments[2]->GenSlidingWindowDeclRef();
-    ss <<"))\n";
-    ss <<"        fDauer = 0;\n    else\n";
+    if(tmpCur2->GetType() == formula::svSingleVectorRef)
+    {
+        const formula::SingleVectorRefToken*tmpCurDVR2= dynamic_cast<const
+        formula::SingleVectorRefToken *>(tmpCur2);
+        ss <<"    if(gid0 >= "<<tmpCurDVR2->GetArrayLength()<<" || isNan(";
+        ss <<vSubArguments[2]->GenSlidingWindowDeclRef();
+        ss <<"))\n";
+        ss <<"        fDauer = 0;\n    else\n";
+    }
 #endif
-    ss <<"        fDauer = "<<vSubArguments[2]->GenSlidingWindowDeclRef();
+    ss <<"        fDauer = ";
+    ss <<vSubArguments[2]->GenSlidingWindowDeclRef();
     ss <<";\n";
 #ifdef ISNAN
-    ss <<"    if(gid0 >= buffer_periode_len || isNan(";
-    ss <<vSubArguments[3]->GenSlidingWindowDeclRef();
-    ss <<"))\n";
-    ss <<"        fPeriode = 0;\n    else\n";
+    if(tmpCur3->GetType() == formula::svSingleVectorRef)
+    {
+        const formula::SingleVectorRefToken*tmpCurDVR3= dynamic_cast<const
+        formula::SingleVectorRefToken *>(tmpCur3);
+        ss <<"    if(gid0 >= "<<tmpCurDVR3->GetArrayLength()<<" || isNan(";
+        ss <<vSubArguments[3]->GenSlidingWindowDeclRef();
+        ss <<"))\n";
+        ss <<"        fPeriode = 0;\n    else\n";
+    }
 #endif
     ss <<"        fPeriode = "<<vSubArguments[3]->GenSlidingWindowDeclRef();
     ss <<";\n";
 #ifdef ISNAN
-    ss <<"    if(gid0 >= buffer_factor_len || isNan(";
-    ss <<vSubArguments[4]->GenSlidingWindowDeclRef();
-    ss <<"))\n";
-    ss <<"        fFaktor = 0;\n    else\n";
+    if(tmpCur4->GetType() == formula::svSingleVectorRef)
+    {
+        const formula::SingleVectorRefToken*tmpCurDVR4= dynamic_cast<const
+        formula::SingleVectorRefToken *>(tmpCur4);
+        ss <<"    if(gid0 >= "<<tmpCurDVR4->GetArrayLength()<<" || isNan(";
+        ss <<vSubArguments[4]->GenSlidingWindowDeclRef();
+        ss <<"))\n";
+        ss <<"        fFaktor = 0;\n    else\n";
+    }
 #endif
     ss <<"        fFaktor = "<<vSubArguments[4]->GenSlidingWindowDeclRef();
     ss <<";\n";
-    ss <<"    fZins = fFaktor / fDauer;\n";
+    ss <<"    fZins = fFaktor * pow(fDauer,-1);\n";
     ss <<"    if (fZins >= 1.0)\n";
     ss <<"    {\n";
     ss <<"        fZins = 1.0;\n";
@@ -5039,15 +5041,14 @@ void OpDDB::GenSlidingWindowFunction(std::stringstream& ss,
     ss <<"            fAlterWert = 0.0;\n";
     ss <<"    }\n";
     ss <<"    else\n";
-    ss <<"        fAlterWert = fWert * pow(1.0 - fZins, fPeriode - 1.0);\n";
+    ss <<"        fAlterWert = fWert * pow(1.0 - fZins, fPeriode - 1);\n";
     ss <<"    fNeuerWert = fWert * pow(1.0 - fZins, fPeriode);\n";
     ss <<"    if (fNeuerWert < fRest)\n";
-    ss <<"        fGda = fAlterWert - fRest;\n";
+    ss <<"        tmp = fAlterWert - fRest;\n";
     ss <<"    else\n";
-    ss <<"        fGda = fAlterWert - fNeuerWert;\n";
-    ss <<"    if (fGda < 0.0)\n";
-    ss <<"        fGda = 0.0;\n";
-    ss <<"    tmp = fGda;\n";
+    ss <<"        tmp = fAlterWert - fNeuerWert;\n";
+    ss <<"    if (tmp < 0.0)\n";
+    ss <<"        tmp = 0.0;\n";
     ss <<"    return tmp;\n";
     ss <<"}";
 }
commit ee48498c5b5dcd5f597d89f03d9b2db995b10f54
Author: mulei <mulei at multicorewareinc.com>
Date:   Fri Dec 20 13:09:08 2013 +0800

    GPU Calc: Optimized PRICEDISC
    
    AMLOEXT-283
    
    Change-Id: I10541f33f65a68d87931d92f520653d7751ae507
    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_financial.cxx b/sc/source/core/opencl/op_financial.cxx
index 71ea858..5c6da78 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -3205,57 +3205,18 @@ void OpPriceDisc::GenSlidingWindowFunction(std::stringstream &ss,
     ss<<"    double tmp2=0;\n";
     ss<<"    double tmp3=0;\n";
     ss<<"    double tmp4=0;\n";
-    size_t nItems = 0;
     ss <<"    \n";
     for (size_t i = 0; i < vSubArguments.size(); i++)
     {
         FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
         assert(pCur);
-        if (pCur->GetType() == formula::svDoubleVectorRef)
-        {
-            const formula::DoubleVectorRefToken* pDVR =
-            dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
-            size_t nCurWindowSize = pDVR->GetRefRowSize();
-            ss << "    for (int i = ";
-            if (!pDVR->IsStartFixed() && pDVR->IsEndFixed()) {
-#ifdef  ISNAN
-                ss << "gid0; i < " << pDVR->GetArrayLength();
-                ss << " && i < " << nCurWindowSize  << "; i++){\n";
-#else
-                ss << "gid0; i < "<< nCurWindowSize << "; i++)\n";
-#endif
-            } else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed()) {
-#ifdef  ISNAN
-                ss << "0; i < " << pDVR->GetArrayLength();
-                ss << " && i < gid0+"<< nCurWindowSize << "; i++){\n";
-#else
-                ss << "0; i < gid0+"<< nCurWindowSize << "; i++)\n";
-#endif
-            } else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed()){
-#ifdef  ISNAN
-                ss << "0; i + gid0 < " << pDVR->GetArrayLength();
-                ss << " &&  i < "<< nCurWindowSize << "; i++){\n";
-#else
-                ss << "0; i < "<< nCurWindowSize << "; i++)\n";
-#endif
-            }
-            else {
-#ifdef  ISNAN
-                ss << "0; i < "<< nCurWindowSize << "; i++){\n";
-#else
-                ss << "0; i < "<< nCurWindowSize << "; i++)\n";
-#endif
-            }
-            nItems += nCurWindowSize;
-        }
-        else if (pCur->GetType() == formula::svSingleVectorRef)
+        if (pCur->GetType() == formula::svSingleVectorRef)
         {
 #ifdef  ISNAN
             const formula::SingleVectorRefToken* pSVR =
             dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
             ss << "    if (gid0 < " << pSVR->GetArrayLength() << "){\n";
 #else
-            nItems += 1;
 #endif
         }
         else if (pCur->GetType() == formula::svDouble)
@@ -3263,13 +3224,11 @@ void OpPriceDisc::GenSlidingWindowFunction(std::stringstream &ss,
 #ifdef  ISNAN
             ss << "{\n";
 #endif
-            nItems += 1;
         }
         else
         {
 #ifdef  ISNAN
 #endif
-            nItems += 1;
         }
 #ifdef  ISNAN
         if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
diff --git a/sc/source/core/opencl/opinlinefun_finacial.cxx b/sc/source/core/opencl/opinlinefun_finacial.cxx
index bb20802..2b81df2 100644
--- a/sc/source/core/opencl/opinlinefun_finacial.cxx
+++ b/sc/source/core/opencl/opinlinefun_finacial.cxx
@@ -1214,8 +1214,7 @@ std::string GetYearDiff=
 "    int   nTotalDays = GetDiffDate( nNullDate, nStartDate, nEndDate,"
 "nMode, &"
 "nDays1stYear );\n"
-"    double result=(double)(nTotalDays)/(nDays1stYear);\n"
-"    return result;\n"
+"     return (double)(nTotalDays)*pow((double)nDays1stYear,-1);\n"
 "}\n";
 
 std::string GetDiffDate360_Decl=
commit d6e0b6fc4982af7877c34980b0419efa1c90bc65
Author: mulei <mulei at multicorewareinc.com>
Date:   Fri Dec 20 12:34:58 2013 +0800

    GPU Calc: Optimized PPMT
    
    AMLOEXT-277
    
    Change-Id: I05b2d703820dab3e284a2356a3e9b1cd9b797247
    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_financial.cxx b/sc/source/core/opencl/op_financial.cxx
index 216e7e9..71ea858 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -3402,129 +3402,90 @@ void OpPPMT::GenSlidingWindowFunction(std::stringstream &ss,
             ss << ", ";
         vSubArguments[i]->GenSlidingWindowDecl(ss);
     }
-    ss << ") {\n    ";
-    ss << "double tmp = 0;\n    ";
-    ss << "int gid0 = get_global_id(0);\n    ";
-    ss<<"double tmp0=0;\n    ";
-    ss<<"double tmp1=0;\n    ";
-    ss<<"double tmp2=0;\n    ";
-    ss<<"double tmp3=0;\n    ";
-    ss<<"double tmp4=0,tmp5=0;\n    ";
-    size_t nItems = 0;
+    ss<<") {\n";
+    ss<<"    double tmp = 0;\n";
+    ss<<"    int gid0 = get_global_id(0);\n";
+    ss<<"    double arg=0;\n";
+    ss<<"    double tmp0=0;\n";
+    ss<<"    double tmp1=0;\n";
+    ss<<"    double tmp2=0;\n";
+    ss<<"    double tmp3=0;\n";
+    ss<<"    double tmp4=0,tmp5=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::svDoubleVectorRef)
-        {
-            const formula::DoubleVectorRefToken* pDVR =
-                dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
-            size_t nCurWindowSize = pDVR->GetRefRowSize();
-            ss << "for (int i = ";
-            if (!pDVR->IsStartFixed() && pDVR->IsEndFixed()) {
-#ifdef  ISNAN
-                ss << "gid0; i < " << pDVR->GetArrayLength();
-                ss << " && i < " << nCurWindowSize  << "; i++){\n        ";
-#else
-                ss << "gid0; i < "<< nCurWindowSize << "; i++)\n        ";
-#endif
-            } else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed()) {
-#ifdef  ISNAN
-                ss << "0; i < " << pDVR->GetArrayLength();
-                ss << " && i < gid0+"<< nCurWindowSize << "; i++){\n        ";
-#else
-                ss << "0; i < gid0+"<< nCurWindowSize << "; i++)\n        ";
-#endif
-            } else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed()){
-#ifdef  ISNAN
-                ss << "0; i + gid0 < " << pDVR->GetArrayLength();
-                ss << " &&  i < "<< nCurWindowSize << "; i++){\n        ";
-#else
-                ss << "0; i < "<< nCurWindowSize << "; i++)\n        ";
-#endif
-            }
-            else {
-#ifdef  ISNAN
-                ss << "0; i < "<< nCurWindowSize << "; i++){\n        ";
-#else
-                ss << "0; i < "<< nCurWindowSize << "; i++)\n        ";
-#endif
-            }
-            nItems += nCurWindowSize;
-        }
-        else if (pCur->GetType() == formula::svSingleVectorRef)
+        if (pCur->GetType() == formula::svSingleVectorRef)
         {
 #ifdef  ISNAN
             const formula::SingleVectorRefToken* pSVR =
                 dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
-            ss << "if (gid0 < " << pSVR->GetArrayLength() << "){\n        ";
+            ss << "if (gid0 < " << pSVR->GetArrayLength() << "){\n";
 #else
-            nItems += 1;
 #endif
         }
         else if (pCur->GetType() == formula::svDouble)
         {
 #ifdef  ISNAN
-            ss << "{\n        ";
+            ss << "{\n";
 #endif
-            nItems += 1;
         }
         else
         {
 #ifdef  ISNAN
 #endif
-            nItems += 1;
         }
 #ifdef  ISNAN
         if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
         {
-            ss << "if (isNan(";
+            ss << "        arg=";
             ss << vSubArguments[i]->GenSlidingWindowDeclRef();
-            ss << "))\n            ";
-            ss << "tmp"<<i<<"= 0;\n        ";
-            ss << "else\n            ";
-            ss << "tmp"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
-            ss << ";\n    }\n    ";
+            ss << ";\n";
+            ss << "        if (isNan(arg))\n";
+            ss << "            tmp"<<i<<"= 0;\n";
+            ss << "        else\n";
+            ss << "            tmp"<<i<<"=arg;\n";
+            ss << "    }\n";
         }
         else
         {
-            ss << "tmp"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
-            ss <<";\n    ";
+            ss<<"    tmp"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss<<";\n";
         }
 #else
-        ss << "tmp"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
-        ss <<";\n    ";
+        ss<<"tmp"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
+        ss<<";\n";
 #endif
     }
-    ss <<"double pmt ;\n    ";
-    ss<<"if(tmp0==0.0)\n    ";
-    ss<<"    return -(tmp3+tmp4)/";
-    ss<<"tmp2;\n    double temp1=0;\n    ";
-    ss <<"double abl = pow(1.0+tmp0,tmp2);\n    ";
-    ss <<"temp1-=tmp4";
-    ss<<";\n    ";
-    ss<<"temp1-=tmp3*abl;\n    ";
-    ss <<"pmt = temp1/(1.0+tmp0*tmp5";
-    ss<<") / ( (abl-1.0)/tmp0);\n    ";
-    ss <<"double temp = pow( 1+tmp0,tmp1-2);\n    ";
-    ss <<"double re;\n    ";
-    ss <<"if(tmp1==1.0)\n    {\n    ";
-    ss <<"if(tmp5>0.0)\n    ";
-    ss <<"    re=0.0;\n    ";
-    ss << "else\n        re=-tmp3;\n    }\n    ";
-    ss <<"else\n    {\n    ";
-    ss <<"if(tmp5>0.0)\n    ";
-    ss <<"    re=GetZw(tmp0, tmp1-2.0, pmt, tmp3, 1.0) - pmt;\n    ";
-    ss <<"else\n    ";
-    ss <<"    re=GetZw(tmp0, tmp1-1.0, pmt, tmp3, 0.0);\n    ";
-    ss <<"}\n    ";
-    ss <<"re = re * tmp0;\n    ";
-    ss <<"tmp = pmt - re;\n    ";
-    ss << "return tmp;\n";
-    ss << "}";
+    ss<<"    double pmt=0 ;\n";
+    ss<<"    if(tmp0==0.0)\n";
+    ss<<"        return -(tmp3+tmp4)/tmp2;\n";
+    ss<<"    pmt=pmt-tmp4-tmp3*pow(1.0+tmp0,tmp2);\n";
+    ss<<"    pmt=pmt*pow(( (1.0+tmp0*tmp5)* ";
+    ss<<"( (pow(1.0+tmp0,tmp2)-1.0)/tmp0)),-1);\n";
+    ss<<"    double temp = pow( 1+tmp0,tmp1-2);\n";
+    ss<<"    double re;\n";
+    ss<<"    if(tmp1==1.0){\n";
+    ss<<"        if(tmp5>0.0)\n";
+    ss<<"            re=0.0;\n";
+    ss<<"        else\n";
+    ss<<"            re=-tmp3;\n";
+    ss<<"    }\n";
+    ss<<"    else\n";
+    ss<<"    {\n";
+    ss<<"        if(tmp5>0.0)\n    ";
+    ss<<"            re=GetZw(tmp0, tmp1-2.0, pmt, tmp3, 1.0) - pmt;\n";
+    ss<<"        else\n";
+    ss<<"            re=GetZw(tmp0, tmp1-1.0, pmt, tmp3, 0.0);\n";
+    ss<<"    }\n    ";
+    ss<<"    re = re * tmp0;\n";
+    ss<<"    tmp = pmt - re;\n";
+    ss<<"    return tmp;\n";
+    ss<<"}";
 }
+
 void OpCoupdaybs::BinInlineFun(std::set<std::string>& decls,
     std::set<std::string>& funs)
 {
commit 905c02ffee26587db76e0067458740ecc4b9e39d
Author: mingli <mingli at multicorewareinc.com>
Date:   Fri Dec 20 12:24:57 2013 +0800

    GPU Calc: Optimized GAMMADIST
    
    AMLOEXT-278 FIX
    
    Change-Id: I59bf06c1e8ef138e08a7699fa167034442780322
    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 df92b8b..8275aaa 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -6562,71 +6562,101 @@ void OpGammaDist::BinInlineFun(std::set<std::string>& decls,
 void OpGammaDist::GenSlidingWindowFunction(std::stringstream &ss,
             const std::string sSymName, SubArguments &vSubArguments)
 {
-        FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken();
-        const formula::SingleVectorRefToken*tmpCurDVR0= dynamic_cast<const
-formula::SingleVectorRefToken *>(tmpCur0);
-        FormulaToken *tmpCur1 = vSubArguments[1]->GetFormulaToken();
-        const formula::SingleVectorRefToken*tmpCurDVR1= dynamic_cast<const
-formula::SingleVectorRefToken *>(tmpCur1);
-        FormulaToken *tmpCur2 = vSubArguments[2]->GetFormulaToken();
-        const formula::SingleVectorRefToken*tmpCurDVR2= dynamic_cast<const
-formula::SingleVectorRefToken *>(tmpCur2);
-        FormulaToken *tmpCur3 = vSubArguments[3]->GetFormulaToken();
-        const formula::SingleVectorRefToken*tmpCurDVR3= dynamic_cast<const
-formula::SingleVectorRefToken *>(tmpCur3);
-        ss << "\ndouble " << sSymName;
-        ss << "_"<< BinFuncName() <<"(";
-        for (unsigned i = 0; i < vSubArguments.size(); i++)
+    ss << "\ndouble " << sSymName;
+    ss << "_"<< BinFuncName() <<"(";
+    for (unsigned i = 0; i < vSubArguments.size(); i++)
+    {
+        if (i)
+            ss << ",";
+        vSubArguments[i]->GenSlidingWindowDecl(ss);
+    }
+    ss << ") {\n";
+    ss << "    int gid0=get_global_id(0);\n";
+    ss << "    double tmp;\n";
+    ss << "    double arg0,arg1,arg2,arg3;\n";
+    size_t i = vSubArguments.size();
+    size_t nItems = 0;
+    for (i = 0; i < vSubArguments.size(); i++)
+    {
+        FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
+        assert(pCur);
+        if (pCur->GetType() == formula::svDoubleVectorRef)
         {
-            if (i)
-                ss << ",";
-            vSubArguments[i]->GenSlidingWindowDecl(ss);
-        }
-        ss << ") {\n";
-        ss << "    int gid0=get_global_id(0);\n";
-        ss << "    double arg0 = ";
-        ss << vSubArguments[0]->GenSlidingWindowDeclRef();
-        ss << ";\n";
-        ss << "    double arg1 = ";
-        ss << vSubArguments[1]->GenSlidingWindowDeclRef();
-        ss << ";\n";
-        ss << "    double arg2 = ";
-        ss << vSubArguments[2]->GenSlidingWindowDeclRef();
-        ss << ";\n";
-        ss << "    double arg3 = ";
-        ss << vSubArguments[3]->GenSlidingWindowDeclRef();
-        ss << ";\n";
-        ss << "    double tmp;\n";
-#ifdef ISNAN
-        ss << "    if(isNan(arg0)||(gid0>=";
-        ss << tmpCurDVR0->GetArrayLength();
-        ss << "))\n";
-        ss << "        arg0 = 0;\n";
+            const formula::DoubleVectorRefToken* pDVR =
+            dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
+            size_t nCurWindowSize = pDVR->GetRefRowSize();
+            ss << "for (int i = ";
+            if (!pDVR->IsStartFixed() && pDVR->IsEndFixed()) {
+#ifdef  ISNAN
+                ss << "gid0; i < " << pDVR->GetArrayLength();
+                ss << " && i < " << nCurWindowSize  << "; i++){\n";
+#else
+                ss << "gid0; i < "<< nCurWindowSize << "; i++)\n";
 #endif
-#ifdef ISNAN
-        ss << "    if(isNan(arg1)||(gid0>=";
-        ss << tmpCurDVR1->GetArrayLength();
-        ss << "))\n";
-        ss << "        arg1 = 0;\n";
+            } else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed()) {
+#ifdef  ISNAN
+                ss << "0; i < " << pDVR->GetArrayLength();
+                ss << " && i < gid0+"<< nCurWindowSize << "; i++){\n";
+#else
+                ss << "0; i < gid0+"<< nCurWindowSize << "; i++)\n ";
 #endif
-#ifdef ISNAN
-        ss << "    if(isNan(arg2)||(gid0>=";
-        ss << tmpCurDVR2->GetArrayLength();
-        ss << "))\n";
-        ss << "        arg2 = 0;\n";
+            } else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed()){
+#ifdef  ISNAN
+                ss << "0; i + gid0 < " << pDVR->GetArrayLength();
+                ss << " &&  i < "<< nCurWindowSize << "; i++){\n ";
+#else
+                ss << "0; i < "<< nCurWindowSize << "; i++)\n";
 #endif
-#ifdef ISNAN
-        ss << "    if(isNan(arg3)||(gid0>=";
-        ss << tmpCurDVR3->GetArrayLength();
-        ss << "))\n";
-        ss << "        arg3 = 0;\n";
+            }
+            else {
+#ifdef  ISNAN
+                ss << "0; i < "<< nCurWindowSize << "; i++){\n";
+#else
+                ss << "0; i < "<< nCurWindowSize << "; i++)\n";
 #endif
-        ss << "    if (arg3)\n";
-        ss << "        tmp=GetGammaDist( arg0, arg1, arg2);\n";
-        ss << "    else\n";
-        ss << "        tmp=GetGammaDistPDF( arg0, arg1, arg2);\n";
-        ss << "    return tmp;\n";
-        ss << "}\n";
+            }
+            nItems += nCurWindowSize;
+        }
+        else if (pCur->GetType() == formula::svSingleVectorRef)
+        {
+#ifdef  ISNAN
+            const formula::SingleVectorRefToken* pSVR =
+                dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
+            ss << "    if (gid0 < " << pSVR->GetArrayLength() << ")\n";
+            ss << "    {\n";
+            ss << "        if (isNan(";
+            ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss << "))\n";
+            ss << "            arg"<<i<<"= 0;\n";
+            ss << "        else\n";
+            ss << "            arg"<<i<<"=";
+            ss<<vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss << ";\n";
+            ss << "    }\n";
+            ss << "    else\n";
+            ss << "        arg"<<i<<"= 0;\n";
+#endif
+        }
+        else if (pCur->GetType() == formula::svDouble)
+        {
+#ifdef  ISNAN
+            ss << "    if (isNan(";
+            ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss << "))\n";
+            ss << "        arg"<<i<<"= 0;\n";
+            ss << "    else\n";
+            ss << "        arg"<<i<<"=";
+            ss <<vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss << ";\n";
+#endif
+        }
+    }
+    ss << "    if (arg3)\n";
+    ss << "        tmp=GetGammaDist( arg0, arg1, arg2);\n";
+    ss << "    else\n";
+    ss << "        tmp=GetGammaDistPDF( arg0, arg1, arg2);\n";
+    ss << "    return tmp;\n";
+    ss << "}\n";
 }
 void OpChiDist::BinInlineFun(std::set<std::string>& decls,
     std::set<std::string>& funs)
commit 31aafc3fff19c80ca0b41a8f9cb914a1b9a5c959
Author: Wei Wei <weiwei at multicorewareinc.com>
Date:   Sun Dec 22 16:52:08 2013 -0600

    GPU Calc: fix the bug of wrong test case for
    
    ISEVEN and ISODD
    
    Change-Id: If16b13a22d336d7d21c9034157be0aa38f2415be
    
    Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>

diff --git a/sc/qa/unit/data/xls/opencl/math/iseven.xls b/sc/qa/unit/data/xls/opencl/math/iseven.xls
index 3e842fb..ad285e5 100644
Binary files a/sc/qa/unit/data/xls/opencl/math/iseven.xls and b/sc/qa/unit/data/xls/opencl/math/iseven.xls differ
diff --git a/sc/qa/unit/data/xls/opencl/math/isodd.xls b/sc/qa/unit/data/xls/opencl/math/isodd.xls
index 80dc1c3..399ee01 100644
Binary files a/sc/qa/unit/data/xls/opencl/math/isodd.xls and b/sc/qa/unit/data/xls/opencl/math/isodd.xls differ


More information about the Libreoffice-commits mailing list