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

minwang min at multicorewareinc.com
Wed Nov 13 13:26:19 PST 2013


 sc/inc/formulagroup.hxx                                |    1 
 sc/qa/unit/data/xls/opencl/financial/Couppcd.xls       |binary
 sc/qa/unit/data/xls/opencl/financial/IPMT.xls          |binary
 sc/qa/unit/data/xls/opencl/financial/NPV.xls           |binary
 sc/qa/unit/data/xls/opencl/financial/Oddlprice.xls     |binary
 sc/qa/unit/data/xls/opencl/financial/Oddlyield.xls     |binary
 sc/qa/unit/data/xls/opencl/financial/PriceDisc.xls     |binary
 sc/qa/unit/data/xls/opencl/financial/db.xls            |binary
 sc/qa/unit/data/xls/opencl/statistical/Confidence.xls  |binary
 sc/qa/unit/data/xls/opencl/statistical/Intercept.xls   |binary
 sc/qa/unit/data/xls/opencl/statistical/Norminv.xls     |binary
 sc/qa/unit/data/xls/opencl/statistical/Normsdist.xls   |binary
 sc/qa/unit/data/xls/opencl/statistical/Normsinv.xls    |binary
 sc/qa/unit/data/xls/opencl/statistical/Permut.xls      |binary
 sc/qa/unit/data/xls/opencl/statistical/Permutation.xls |binary
 sc/qa/unit/data/xls/opencl/statistical/Phi.xls         |binary
 sc/qa/unit/opencl-test.cxx                             |  370 +++
 sc/source/core/opencl/formulagroupcl.cxx               |   85 
 sc/source/core/opencl/oclkernels.hxx                   |  390 ---
 sc/source/core/opencl/op_financial.cxx                 |  808 +++++++
 sc/source/core/opencl/op_financial.hxx                 |   67 
 sc/source/core/opencl/op_statistical.cxx               |  779 ++++++
 sc/source/core/opencl/op_statistical.hxx               |   56 
 sc/source/core/opencl/openclwrapper.cxx                | 1931 -----------------
 sc/source/core/opencl/openclwrapper.hxx                |   88 
 sc/source/core/opencl/opinlinefun_finacial.cxx         |  104 
 sc/source/core/opencl/opinlinefun_statistical.cxx      |  183 +
 sc/source/core/tool/formulagroup.cxx                   |   26 
 sc/source/core/tool/token.cxx                          |   11 
 sc/source/filter/ftools/clkernelthread.cxx             |    2 
 writerfilter/source/dmapper/StyleSheetTable.cxx        |    2 
 31 files changed, 2471 insertions(+), 2432 deletions(-)

New commits:
commit 709802e3e5f48c3b83a569f6850483facc02e72c
Author: minwang <min at multicorewareinc.com>
Date:   Wed Nov 6 14:44:44 2013 +0800

    GPU Calc: unit test cases for COUPPCD
    
    Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-135 BUG
    
    Change-Id: I57822062ea2672fe3d290f11905330fb4e7b8ba5
    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/financial/Couppcd.xls b/sc/qa/unit/data/xls/opencl/financial/Couppcd.xls
new file mode 100644
index 0000000..22689cf
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/financial/Couppcd.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 1b8a95e..0077cc5 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -162,6 +162,7 @@ public:
     void testFinacialOddlyieldFormula();
     void testFinacialPriceDiscFormula();
     void testFinancialDBFormula();
+    void testFinancialCouppcdFormula();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -253,6 +254,7 @@ public:
     CPPUNIT_TEST(testFinacialOddlyieldFormula);
     CPPUNIT_TEST(testFinacialPriceDiscFormula);
     CPPUNIT_TEST(testFinancialDBFormula);
+    CPPUNIT_TEST(testFinancialCouppcdFormula);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -2505,6 +2507,28 @@ void ScOpenclTest::testFinancialDBFormula()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-135]
+void ScOpenclTest::testFinancialCouppcdFormula()
+{
+    if (!detectOpenCLDevice())
+        return;
+    ScDocShellRef xDocSh = loadDoc("opencl/financial/Couppcd.", XLS);
+    ScDocument *pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/financial/Couppcd.", XLS);
+    ScDocument *pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    for (SCROW i = 0; i <= 9; ++i)
+    {
+        double fLibre = pDoc->GetValue(ScAddress(4, i, 0));
+        double fExcel = pDocRes->GetValue(ScAddress(4, i, 0));
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+    }
+    xDocSh->DoClose();
+    xDocShRes->DoClose();
+}
 //[AMLOEXT-128]
 void ScOpenclTest::testMathSumIfsFormula()
 {
commit 5eadb942c86912c882b95637ff6845ea874d775b
Author: minwang <min at multicorewareinc.com>
Date:   Wed Nov 6 14:48:54 2013 +0800

    GPU Calc: implemented for COUPPCD
    
    AMLOEXT-135 FIX
    
    Change-Id: If16217647f85bdd4a309c81b33bc963b9e54f657
    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 e0dc630..1e4f9f2 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1311,6 +1311,12 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                     mvSubArguments.push_back(SoPHelper(ts,
                         ft->Children[i], new OpPriceDisc));
                 }
+                else if ( !(pChild->GetExternal().compareTo(OUString(
+                     "com.sun.star.sheet.addin.Analysis.getCouppcd"))))
+                {
+                    mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],
+                        new OpCouppcd));
+                }
                 break;
             default:
                 throw UnhandledToken(pChild, "unhandled opcode");
diff --git a/sc/source/core/opencl/op_financial.cxx b/sc/source/core/opencl/op_financial.cxx
index b07be2f..e6f1382 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -3468,6 +3468,106 @@ void OpCoupdays::GenSlidingWindowFunction(
     ss << "return tmp;\n";
     ss << "}";
 }
+void OpCouppcd::BinInlineFun(std::set<std::string>& decls,
+    std::set<std::string>& funs)
+{
+    decls.insert(IsLeapYearDecl); decls.insert(DaysInMonthDecl);
+    decls.insert(DaysToDateDecl); decls.insert(DateToDaysDecl);
+    decls.insert(GetNullDateDecl); decls.insert(ScaDate2Decl);
+    decls.insert(lcl_GetCouppcdDecl);
+    funs.insert(IsLeapYear);funs.insert(DaysInMonth);
+    funs.insert(DaysToDate);funs.insert(DateToDays);
+    funs.insert(GetNullDate);funs.insert(ScaDate2);
+    funs.insert(lcl_GetCouppcd);
+}
+void OpCouppcd::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 << "    int bLastDayMode =1,bLastDay =0,b30Days= 0,bUSMode = 0;\n";
+    ss << "    int nSettle,nMat,nFreq,nBase;\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);
+    ss<< "    int buffer_nSettle_len = ";
+    ss<< tmpCurDVR0->GetArrayLength();
+    ss << ";\n";
+    ss<< "    int buffer_nMat_len = ";
+    ss<< tmpCurDVR1->GetArrayLength();
+    ss << ";\n";
+    ss<< "    int buffer_nFreq_len = ";
+    ss<< tmpCurDVR2->GetArrayLength();
+    ss << ";\n";
+    ss<< "    int buffer_nBase_len = ";
+    ss<< tmpCurDVR3->GetArrayLength();
+    ss << ";\n";
+#endif
+#ifdef ISNAN
+    ss <<"    if(gid0 >= buffer_nSettle_len || isNan(";
+    ss <<vSubArguments[0]->GenSlidingWindowDeclRef();
+    ss <<"))\n";
+    ss <<"        nSettle = 0;\n    else\n";
+#endif
+   ss << "        nSettle=(int)";
+   ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+   ss <<";\n";
+#ifdef ISNAN
+    ss <<"    if(gid0 >= buffer_nMat_len || isNan(";
+    ss <<vSubArguments[1]->GenSlidingWindowDeclRef();
+    ss <<"))\n";
+    ss <<"        nMat = 0;\n    else\n";
+#endif
+    ss <<"        nMat=(int)";
+    ss << vSubArguments[1]->GenSlidingWindowDeclRef();
+    ss << ";\n";
+#ifdef ISNAN
+    ss <<"    if(gid0 >= buffer_nFreq_len || isNan(";
+    ss <<vSubArguments[2]->GenSlidingWindowDeclRef();
+    ss <<"))\n";
+    ss <<"        nFreq = 0;\n    else\n";
+#endif
+    ss <<"        nFreq=(int)";
+    ss <<vSubArguments[2]->GenSlidingWindowDeclRef();
+    ss <<";\n";
+#ifdef ISNAN
+    ss <<"    if(gid0 >= buffer_nBase_len || isNan(";
+    ss <<vSubArguments[3]->GenSlidingWindowDeclRef();
+    ss <<"))\n";
+    ss <<"        nBase = 0;\n    else\n";
+#endif
+    ss <<"        nBase=(int)";
+    ss << vSubArguments[3]->GenSlidingWindowDeclRef();
+    ss <<";\n";
+    ss <<"    int nNullDate=GetNullDate();\n";
+    ss <<"    ScaDate2(nNullDate, nMat, nBase,&bLastDayMode,&bLastDay,";
+    ss <<"&b30Days,&bUSMode);\n";
+    ss <<"    tmp = lcl_GetCouppcd(nNullDate,nSettle,nMat,nFreq,";
+    ss <<"&bLastDayMode,&bLastDay,&b30Days,&bUSMode);\n";
+    ss <<"    return tmp;\n";
+    ss <<"}";
+}
+
 void OpCoupdaysnc::BinInlineFun(std::set<std::string>& decls,
     std::set<std::string>& funs)
 {
diff --git a/sc/source/core/opencl/op_financial.hxx b/sc/source/core/opencl/op_financial.hxx
index 4118236..9686587 100644
--- a/sc/source/core/opencl/op_financial.hxx
+++ b/sc/source/core/opencl/op_financial.hxx
@@ -410,6 +410,17 @@ public:
     virtual std::string BinFuncName(void) const { return "Coupdaysnc"; }
 
 };
+
+class OpCouppcd: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 "Couppcd"; }
+
+};
+
 class OpCoupnum:public Normal
 {
 public:
diff --git a/sc/source/core/opencl/opinlinefun_finacial.cxx b/sc/source/core/opencl/opinlinefun_finacial.cxx
index fab1db8..7dde5ce 100644
--- a/sc/source/core/opencl/opinlinefun_finacial.cxx
+++ b/sc/source/core/opencl/opinlinefun_finacial.cxx
@@ -225,6 +225,67 @@ std::string ScaDate=
 "    }\n"
 "}\n";
 
+std::string ScaDate2Decl=
+"void ScaDate2( int nNullDate, int nDate, int nBase,int *bLastDayMode,int *"
+"bLastDay,int *b30Days,int *bUSMode);\n";
+
+std::string ScaDate2=
+"void ScaDate2( int nNullDate, int nDate, int nBase,int *bLastDayMode,int *"
+"bLastDay,int *b30Days,int *bUSMode)\n"
+"{\n"
+"    int nOrigDay=0,  nMonth=0,  nYear=0;\n"
+"    DaysToDate( nNullDate + nDate, &nOrigDay, &nMonth, &nYear );\n"
+"    *bLastDayMode = (nBase != 5);\n"
+"    *bLastDay = (nOrigDay >= DaysInMonth( nMonth, nYear ));\n"
+"    *b30Days = (nBase == 0) || (nBase == 4);\n"
+"    *bUSMode = (nBase == 0);\n"
+"}\n";
+
+std::string lcl_GetCouppcdDecl=
+"int lcl_GetCouppcd(int nNullDate,int nSettle, int nMat,int nFreq,int *"
+"bLastDayMode,int *bLastDay,int *b30Days,int *bUSMode);\n";
+
+std::string lcl_GetCouppcd=
+"int lcl_GetCouppcd(int nNullDate,int nSettle, int nMat,int nFreq,int *"
+"bLastDayMode,int *bLastDay,int *b30Days,int *bUSMode)\n"
+"{\n"
+"    int aDate = nMat;int rDay=0,rMonth=0,rYear=0;int mDay=0,mMonth=0,"
+"mYear=0;\n"
+"    int sDay=0,sMonth=0, sYear=0;\n"
+"    DaysToDate(aDate+nNullDate,&rDay, &rMonth, &rYear );\n"
+"    DaysToDate(nMat+nNullDate,&mDay, &mMonth, &mYear );\n"
+"    DaysToDate(nSettle+nNullDate,&sDay, &sMonth, &sYear );\n"
+"    rYear= sYear;\n"
+"    nSettle=nSettle+nNullDate;\n"
+"    aDate=DateToDays( rDay,rMonth,rYear );\n"
+"    if( aDate < nSettle )\n"
+"        rYear+= 1;\n"
+"    int d=DateToDays( rDay,rMonth,rYear );\n"
+"    int nMonthCount=-1*(12 / nFreq);\n"
+"    while(d > nSettle )\n"
+"    {\n"
+"        int nNewMonth = nMonthCount + rMonth;\n"
+"        if( nNewMonth > 12 )\n"
+"        {\n"
+"           --nNewMonth;\n"
+"           rYear+=nNewMonth / 12;\n"
+"           rMonth = nNewMonth % 12 + 1;\n"
+"         }\n"
+"        else if( nNewMonth < 1 )\n"
+"        {\n"
+"           rYear+= nNewMonth / 12 - 1;\n"
+"           rMonth = nNewMonth % 12 + 12;\n"
+"        }\n"
+"        else\n"
+"            rMonth =  nNewMonth;\n"
+"        d=DateToDays( rDay,rMonth,rYear );\n"
+"    }\n"
+"    int nLastDay = DaysInMonth( rMonth, rYear );\n"
+"    int nRealDay = ((*bLastDayMode) && (*bLastDay)) ? nLastDay :"
+"min( nLastDay, rDay );\n"
+"    return DateToDays( nRealDay, rMonth, rYear ) - nNullDate;\n"
+"}\n";
+
 std::string addMonthsDecl=
 "void addMonths(int b30Days,int bLastDay,int *nDay,int nOrigDay,"
 "int *nMonth,int nMonthCount,int *year);\n";
commit 3e0136906b99b573aa1fd7134c93772f22a49739
Author: minwang <min at multicorewareinc.com>
Date:   Wed Nov 6 14:18:10 2013 +0800

    GPU Calc: unit test cases for DB
    
    Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-132 BUG
    
    Change-Id: I89dca4895fd8952ec085a30d42d75e05e0ed96d1
    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/financial/db.xls b/sc/qa/unit/data/xls/opencl/financial/db.xls
new file mode 100644
index 0000000..81cd024
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/financial/db.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 4b73303..1b8a95e 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -161,6 +161,7 @@ public:
     void testFinacialODDLPRICEFormula();
     void testFinacialOddlyieldFormula();
     void testFinacialPriceDiscFormula();
+    void testFinancialDBFormula();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -251,6 +252,7 @@ public:
     CPPUNIT_TEST(testFinacialODDLPRICEFormula);
     CPPUNIT_TEST(testFinacialOddlyieldFormula);
     CPPUNIT_TEST(testFinacialPriceDiscFormula);
+    CPPUNIT_TEST(testFinancialDBFormula);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -2481,6 +2483,28 @@ void ScOpenclTest:: testFinancialFVFormula()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-132]
+void ScOpenclTest::testFinancialDBFormula()
+{
+   if (!detectOpenCLDevice())
+        return;
+    ScDocShellRef xDocSh = loadDoc("opencl/financial/db.", XLS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/financial/db.", XLS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    for (SCROW i = 0; i <= 9; ++i)
+    {
+        double fLibre = pDoc->GetValue(ScAddress(5, i, 0));
+        double fExcel = pDocRes->GetValue(ScAddress(5, i, 0));
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+    }
+    xDocSh->DoClose();
+    xDocShRes->DoClose();
+}
 //[AMLOEXT-128]
 void ScOpenclTest::testMathSumIfsFormula()
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 2a71c96..48d1578 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1396,6 +1396,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocZinsZ:
             case ocConfidence:
             case ocIntercept:
+            case ocGDA2:
             // Don't change the state.
             break;
             default:
commit 95e68edc03313b1043629d85a4c203375729ead1
Author: minwang <min at multicorewareinc.com>
Date:   Wed Nov 6 14:39:25 2013 +0800

    GPU Calc: implemented for DB
    
    AMLOEXT-132 FIX
    
    Change-Id: Ia468999f2d182fab62a8229362dfe2ebbe949654
    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 4df0271..e0dc630 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1136,6 +1136,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 mvSubArguments.push_back(SoPHelper(ts,
                          ft->Children[i], new OpIntercept));
                 break;
+            case ocGDA2:
+                mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],
+                    new OpDB));
+                break;
             case ocExternal:
                 if ( !(pChild->GetExternal().compareTo(OUString(
                     "com.sun.star.sheet.addin.Analysis.getEffect"))))
diff --git a/sc/source/core/opencl/op_financial.cxx b/sc/source/core/opencl/op_financial.cxx
index f81028e..b07be2f 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -4968,7 +4968,120 @@ void OpXirr::GenSlidingWindowFunction(std::stringstream &ss,
     }
 
 }
-
+void OpDB::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 nWert,nRest,nDauer,nPeriode;\n";
+    ss << "    int nMonate;\n";
+    ss << "    double tmp = 0;\n";
+#ifdef ISNAN
+    FormulaToken* tmpCur0 = vSubArguments[0]->GetFormulaToken();
+    const formula::SingleVectorRefToken*tmpCurDVR0= dynamic_cast<const
+    formula::SingleVectorRefToken *>(tmpCur0);
+    FormulaToken* tmpCur1 = vSubArguments[1]->GetFormulaToken();
+    const formula::SingleVectorRefToken*tmpCurDVR1= dynamic_cast<const
+    formula::SingleVectorRefToken *>(tmpCur1);
+    FormulaToken* tmpCur2 = vSubArguments[2]->GetFormulaToken();
+    const formula::SingleVectorRefToken*tmpCurDVR2= dynamic_cast<const
+    formula::SingleVectorRefToken *>(tmpCur2);
+    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_nMonate_len = ";
+    ss<< tmpCurDVR4->GetArrayLength();
+    ss << ";\n";
+#endif
+#ifdef ISNAN
+    ss <<"    if(gid0 >= buffer_wert_len || isNan(";
+    ss <<vSubArguments[0]->GenSlidingWindowDeclRef();
+    ss <<"))\n";
+    ss <<"        nWert = 0;\n    else\n";
+#endif
+    ss <<"        nWert = "<<vSubArguments[0]->GenSlidingWindowDeclRef();
+    ss <<";\n";
+#ifdef ISNAN
+    ss <<"    if(gid0 >= buffer_rest_len || isNan(";
+    ss <<vSubArguments[1]->GenSlidingWindowDeclRef();
+    ss <<"))\n";
+    ss <<"        nRest = 0;\n    else\n";
+#endif
+    ss <<"        nRest = ";
+    ss <<vSubArguments[1]->GenSlidingWindowDeclRef();
+    ss <<";\n";
+#ifdef ISNAN
+    ss <<"    if(gid0 >= buffer_dauer_len || isNan(";
+    ss <<vSubArguments[2]->GenSlidingWindowDeclRef();
+    ss <<"))\n";
+    ss <<"        nDauer = 0;\n    else\n";
+#endif
+    ss <<"        nDauer = "<<vSubArguments[2]->GenSlidingWindowDeclRef();
+    ss <<";\n";
+#ifdef ISNAN
+    ss <<"    if(gid0 >= buffer_periode_len || isNan(";
+    ss <<vSubArguments[3]->GenSlidingWindowDeclRef();
+    ss <<"))\n";
+    ss <<"        nPeriode = 0;\n    else\n";
+#endif
+    ss <<"        nPeriode = "<<vSubArguments[3]->GenSlidingWindowDeclRef();
+    ss <<";\n";
+#ifdef ISNAN
+    ss <<"    if(gid0 >= buffer_nMonate_len || isNan(";
+    ss <<vSubArguments[4]->GenSlidingWindowDeclRef();
+    ss <<"))\n";
+    ss <<"        nMonate = 0;\n    else\n";
+#endif
+    ss <<"        nMonate = (int)"<<vSubArguments[4]->GenSlidingWindowDeclRef();
+    ss <<";\n";
+    ss <<"    double nAbRate = 1.0 - pow(nRest / nWert, 1.0 / nDauer);\n";
+    ss <<"    nAbRate = ((int)(nAbRate * 1000.0 + 0.5)) / 1000.0;\n";
+    ss <<"    double nErsteAbRate = nWert * nAbRate * nMonate / 12.0;\n";
+    ss <<"    double nGda2 = 0.0;\n";
+    ss <<"    if ((int)(nPeriode) == 1)\n";
+    ss <<"        nGda2 = nErsteAbRate;\n";
+    ss <<"    else\n";
+    ss <<"    {\n";
+    ss <<"        double nSummAbRate = nErsteAbRate;\n";
+    ss <<"        double nMin = nDauer;\n";
+    ss <<"        if (nMin > nPeriode) nMin = nPeriode;\n";
+    ss <<"        int iMax = (int)nMin;\n";
+    ss <<"        for (int i = 2; i <= iMax; i++)\n";
+    ss <<"        {\n";
+    ss <<"            nGda2 = (nWert - nSummAbRate) * nAbRate;\n";
+    ss <<"            nSummAbRate += nGda2;\n";
+    ss <<"        }\n";
+    ss <<"        if (nPeriode > nDauer)\n";
+    ss <<"            nGda2 = ((nWert - nSummAbRate)";
+    ss <<"* nAbRate * (12.0 - nMonate)) / 12.0;\n";
+    ss <<"    }\n";
+    ss <<"    tmp = nGda2;\n";
+    ss <<"    return tmp;\n";
+    ss <<"}";
+}
 }}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/opencl/op_financial.hxx b/sc/source/core/opencl/op_financial.hxx
index 1843fcf..4118236 100644
--- a/sc/source/core/opencl/op_financial.hxx
+++ b/sc/source/core/opencl/op_financial.hxx
@@ -428,7 +428,14 @@ public:
 
      virtual std::string BinFuncName(void) const { return "DDB"; }
 };
+class OpDB:public Normal
+{
+public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+            const std::string sSymName, SubArguments &vSubArguments);
 
+     virtual std::string BinFuncName(void) const { return "DB"; }
+};
 class OpAmordegrc:public Normal
 {
 public:
commit b5a92852dff1027e8b99c6c3efbecba31de37c4f
Author: mulei <mulei at multicorewareinc.com>
Date:   Wed Nov 6 13:52:19 2013 +0800

    GPU Calc: unit test cases for PRICEDISC
    
    Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-65 BUG
    
    Change-Id: I69fab20b90fade63cb8084a5993f597cfe7a1e48
    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/financial/PriceDisc.xls b/sc/qa/unit/data/xls/opencl/financial/PriceDisc.xls
new file mode 100644
index 0000000..16269e93
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/financial/PriceDisc.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 1c15e0e..4b73303 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -160,6 +160,7 @@ public:
     void testStatisticalFormulaIntercept();
     void testFinacialODDLPRICEFormula();
     void testFinacialOddlyieldFormula();
+    void testFinacialPriceDiscFormula();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -249,6 +250,7 @@ public:
     CPPUNIT_TEST(testStatisticalFormulaIntercept);
     CPPUNIT_TEST(testFinacialODDLPRICEFormula);
     CPPUNIT_TEST(testFinacialOddlyieldFormula);
+    CPPUNIT_TEST(testFinacialPriceDiscFormula);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1375,6 +1377,28 @@ void ScOpenclTest::testFinacialDollarfrFormula()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-65]
+void ScOpenclTest::testFinacialPriceDiscFormula()
+{
+    if (!detectOpenCLDevice())
+        return;
+    ScDocShellRef xDocSh = loadDoc("opencl/financial/PriceDisc.", XLS);
+    ScDocument *pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/financial/PriceDisc.", XLS);
+    ScDocument *pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    for (SCROW i = 0; i <= 10; ++i)
+    {
+        double fLibre = pDoc->GetValue(ScAddress(5, i, 0));
+        double fExcel = pDocRes->GetValue(ScAddress(5, i, 0));
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+    }
+    xDocSh->DoClose();
+    xDocShRes->DoClose();
+}
 //[AMLOEXT-67]
 void ScOpenclTest::testFinacialODDLPRICEFormula()
 {
commit f4bc89e9a7a81623f5929adc0935a0a07bdc65f3
Author: mulei <mulei at multicorewareinc.com>
Date:   Wed Nov 6 13:57:00 2013 +0800

    GPU Calc: implemented for PRICEDISC
    
    AMLOEXT-65 FIX
    
    Change-Id: Ia4dfefe0cce42f30a89a4e25366be5f8f526c471
    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 41509cc..4df0271 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1301,6 +1301,12 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                     mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],
                         new OpOddlyield));
                 }
+                else if ( !(pChild->GetExternal().compareTo(OUString(
+                    "com.sun.star.sheet.addin.Analysis.getPricedisc"))))
+                {
+                    mvSubArguments.push_back(SoPHelper(ts,
+                        ft->Children[i], new OpPriceDisc));
+                }
                 break;
             default:
                 throw UnhandledToken(pChild, "unhandled opcode");
diff --git a/sc/source/core/opencl/op_financial.cxx b/sc/source/core/opencl/op_financial.cxx
index 1947133..f81028e 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -2919,6 +2919,139 @@ void OpOddlyield::GenSlidingWindowFunction(std::stringstream &ss,
     ss <<"    return tmp;\n";
     ss <<"}";
 }
+void OpPriceDisc::BinInlineFun(std::set<std::string>& decls,
+     std::set<std::string>& funs)
+{
+    decls.insert(GetYearDiffDecl);decls.insert(getDiffDecl);
+    decls.insert(getDaysInYearRangeDecl);decls.insert(GetDaysInYearDecl);
+    decls.insert(GetDaysInYearsDecl);decls.insert(getDaysInMonthRangeDecl);
+    decls.insert(addMonthsDecl);decls.insert(ScaDateDecl);
+    decls.insert(GetNullDateDecl);decls.insert(DateToDaysDecl);
+    decls.insert(DaysToDateDecl);decls.insert(DaysInMonthDecl);
+    decls.insert(IsLeapYearDecl);decls.insert(GetDiffDateDecl);
+    funs.insert(GetYearDiff);funs.insert(getDiff);
+    funs.insert(getDaysInYearRange);funs.insert(GetDaysInYear);
+    funs.insert(GetDaysInYears);funs.insert(getDaysInMonthRange);
+    funs.insert(addMonths);funs.insert(ScaDate);
+    funs.insert(GetNullDate);funs.insert(DateToDays);
+    funs.insert(DaysToDate);funs.insert(DaysInMonth);
+    funs.insert(IsLeapYear);funs.insert(GetDiffDate);
+}
+void OpPriceDisc::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 tmp0=0;\n";
+    ss<<"    double tmp1=0;\n";
+    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)
+        {
+#ifdef  ISNAN
+            const formula::SingleVectorRefToken* pSVR =
+            dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
+            ss << "    if (gid0 < " << pSVR->GetArrayLength() << "){\n";
+#else
+            nItems += 1;
+#endif
+        }
+        else if (pCur->GetType() == formula::svDouble)
+        {
+#ifdef  ISNAN
+            ss << "{\n";
+#endif
+            nItems += 1;
+        }
+        else
+        {
+#ifdef  ISNAN
+#endif
+            nItems += 1;
+        }
+#ifdef  ISNAN
+        if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
+        {
+            ss << "        if (isNan(";
+            ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss << "))\n";
+            ss << "            tmp"<<i<<"= 0;\n";
+            ss << "        else\n";
+            ss << "            tmp"<<i<<"=";
+            ss <<vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss << ";\n";
+            ss <<"    }\n";
+        }
+        else
+        {
+            ss << "        tmp"<<i<<"=";
+            ss <<vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss <<";\n";
+        }
+#else
+    ss << "        tmp"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
+    ss <<";\n";
+#endif
+    }
+    ss <<"    int nNullDate = GetNullDate();\n";
+    ss <<"    tmp=tmp3* ( 1.0 -tmp2*GetYearDiff( nNullDate, ";
+    ss <<"tmp0,tmp1,tmp4));\n";
+    ss <<"    return tmp;\n";
+    ss <<"}";
+}
 void OpNPER::GenSlidingWindowFunction(std::stringstream &ss,
       const std::string sSymName, SubArguments &vSubArguments)
 {
diff --git a/sc/source/core/opencl/op_financial.hxx b/sc/source/core/opencl/op_financial.hxx
index 4efd1e3..1843fcf 100644
--- a/sc/source/core/opencl/op_financial.hxx
+++ b/sc/source/core/opencl/op_financial.hxx
@@ -360,6 +360,15 @@ public:
         std::set<std::string>& );
     virtual std::string BinFuncName(void) const { return "Oddlyield"; }
 };
+class OpPriceDisc: 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 "PriceDisc"; }
+};
 class OpPPMT: public Normal
 {
 public:
commit 73ebb0e61b4f8b6c456d85367c09b184e6566881
Author: mulei <mulei at multicorewareinc.com>
Date:   Wed Nov 6 13:39:17 2013 +0800

    GPU Calc: unit test cases for ODDLYIELD
    
    Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-68 BUG
    
    Change-Id: I432fdb4fbab18e5689c2a657b679a57424261c43
    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/financial/Oddlyield.xls b/sc/qa/unit/data/xls/opencl/financial/Oddlyield.xls
new file mode 100644
index 0000000..daaa0d2
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/financial/Oddlyield.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index e4b284d..1c15e0e 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -159,6 +159,7 @@ public:
     void testStatisticalFormulaConfidence();
     void testStatisticalFormulaIntercept();
     void testFinacialODDLPRICEFormula();
+    void testFinacialOddlyieldFormula();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -247,6 +248,7 @@ public:
     CPPUNIT_TEST(testStatisticalFormulaConfidence);
     CPPUNIT_TEST(testStatisticalFormulaIntercept);
     CPPUNIT_TEST(testFinacialODDLPRICEFormula);
+    CPPUNIT_TEST(testFinacialOddlyieldFormula);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1395,6 +1397,28 @@ void ScOpenclTest::testFinacialODDLPRICEFormula()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-68]
+void ScOpenclTest:: testFinacialOddlyieldFormula()
+{
+    if (!detectOpenCLDevice())
+        return;
+    ScDocShellRef xDocSh = loadDoc("opencl/financial/Oddlyield.", XLS);
+    ScDocument *pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/financial/Oddlyield.", XLS);
+    ScDocument *pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    for (SCROW i = 0; i <= 6; ++i)
+    {
+        double fLibre = pDoc->GetValue(ScAddress(8, i, 0));
+        double fExcel = pDocRes->GetValue(ScAddress(8, i, 0));
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+    }
+    xDocSh->DoClose();
+    xDocShRes->DoClose();
+}
 //[AMLOEXT-71]
 void ScOpenclTest::testFinacialDISCFormula()
 {
commit 7e4849dcbe3e92cb1047c726d14e7fd4d223be08
Author: mulei <mulei at multicorewareinc.com>
Date:   Wed Nov 6 13:45:39 2013 +0800

    GPU Calc: implemented for ODDLYIELD
    
    AMLOEXT-68 FIX
    
    Change-Id: I5a955a7488829621cf4ad905239f915784b1f374
    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 fa89cc7..41509cc 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1295,6 +1295,12 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                     mvSubArguments.push_back(SoPHelper(ts,
                         ft->Children[i], new OpOddlprice));
                 }
+                else if ( !(pChild->GetExternal().compareTo(OUString(
+                     "com.sun.star.sheet.addin.Analysis.getOddlyield"))))
+                {
+                    mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],
+                        new OpOddlyield));
+                }
                 break;
             default:
                 throw UnhandledToken(pChild, "unhandled opcode");
diff --git a/sc/source/core/opencl/op_financial.cxx b/sc/source/core/opencl/op_financial.cxx
index 21a8f47..1947133 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -2787,6 +2787,138 @@ void OpOddlprice::GenSlidingWindowFunction(std::stringstream &ss,
     ss <<"    return tmp;\n";
     ss <<"}";
 }
+void OpOddlyield::BinInlineFun(std::set<std::string>& decls,
+     std::set<std::string>& funs)
+{
+    decls.insert(GetDiffDateDecl);decls.insert(DaysToDateDecl);
+    decls.insert(GetYearDiffDecl);decls.insert(IsLeapYearDecl);
+    decls.insert(GetNullDateDecl);decls.insert(DateToDaysDecl);
+    decls.insert(DaysInMonthDecl);
+    decls.insert(GetYearFracDecl);decls.insert(GetOddlyieldDecl);
+    funs.insert(GetDiffDate);funs.insert(DaysToDate);
+    funs.insert(GetYearDiff);funs.insert(IsLeapYear);
+    funs.insert(GetNullDate);funs.insert(DaysInMonth);
+    funs.insert(DateToDays);
+    funs.insert(GetYearFrac);funs.insert(GetOddlyield);
+}
+void OpOddlyield::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 tmp0=0;\n";
+    ss <<"    double tmp1=0;\n";
+    ss <<"    double tmp2=0;\n";
+    ss <<"    double tmp3=0;\n";
+    ss <<"    double tmp4=0;\n";
+    ss <<"    double tmp5=0;\n";
+    ss <<"    double tmp6=0;\n";
+    ss <<"    double tmp7=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)
+        {
+#ifdef  ISNAN
+            const formula::SingleVectorRefToken* pSVR =
+            dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
+            ss << "    if (gid0 < " << pSVR->GetArrayLength() << "){\n";
+#else
+            nItems += 1;
+#endif
+        }
+        else if (pCur->GetType() == formula::svDouble)
+        {
+#ifdef  ISNAN
+            ss << "{\n";
+#endif
+            nItems += 1;
+        }
+        else
+        {
+#ifdef  ISNAN
+#endif
+            nItems += 1;
+        }
+#ifdef  ISNAN
+        if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
+        {
+            ss << "        if (isNan(";
+            ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss << "))\n";
+            ss << "            tmp"<<i<<"= 0;\n";
+            ss << "        else\n";
+            ss << "            tmp"<<i<<"=";
+            ss <<vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss << ";\n";
+            ss <<"    }\n";
+        }
+        else
+        {
+            ss << "        tmp"<<i<<"=";
+            ss <<vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss <<";\n";
+        }
+#else
+    ss << "        tmp"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
+    ss <<";\n";
+#endif
+    }
+    ss <<"    int nNullDate = GetNullDate();\n";
+    ss <<"    tmp = GetOddlyield(nNullDate,tmp0,tmp1";
+    ss <<",tmp2,tmp3,tmp4,tmp5,tmp6,tmp7);\n";
+    ss <<"    return tmp;\n";
+    ss <<"}";
+}
 void OpNPER::GenSlidingWindowFunction(std::stringstream &ss,
       const std::string sSymName, SubArguments &vSubArguments)
 {
diff --git a/sc/source/core/opencl/op_financial.hxx b/sc/source/core/opencl/op_financial.hxx
index 6c886f9..4efd1e3 100644
--- a/sc/source/core/opencl/op_financial.hxx
+++ b/sc/source/core/opencl/op_financial.hxx
@@ -351,6 +351,15 @@ public:
         std::set<std::string>& );
     virtual std::string BinFuncName(void) const { return "Oddlprice"; }
 };
+class OpOddlyield: 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 "Oddlyield"; }
+};
 class OpPPMT: public Normal
 {
 public:
diff --git a/sc/source/core/opencl/opinlinefun_finacial.cxx b/sc/source/core/opencl/opinlinefun_finacial.cxx
index 5e51470..fab1db8 100644
--- a/sc/source/core/opencl/opinlinefun_finacial.cxx
+++ b/sc/source/core/opencl/opinlinefun_finacial.cxx
@@ -1153,6 +1153,24 @@ std::string GetOddlprice=
 "    return p;\n"
 "}\n";
 
+std::string GetOddlyieldDecl=
+"double GetOddlyield( int nNullDate, int nSettle, int nMat, int nLastCoup,\n"
+"    double fRate, double fPrice, double fRedemp, int nFreq, int nBase );\n";
+
+std::string GetOddlyield=
+"double GetOddlyield( int nNullDate, int nSettle, int nMat, int nLastCoup,\n"
+"    double fRate, double fPrice, double fRedemp, int nFreq, int nBase ) \n"
+"{\n"
+"    double fFreq =  nFreq ;\n"
+"    double fDCi= GetYearFrac( nNullDate, nLastCoup, nMat, nBase ) * fFreq;\n"
+"    double fDSCi= GetYearFrac( nNullDate, nSettle, nMat, nBase ) * fFreq;\n"
+"    double fAi= GetYearFrac( nNullDate, nLastCoup, nSettle, nBase )*fFreq;\n"
+"    double y = fRedemp + fDCi * 100.0 * fRate / fFreq;\n"
+"    y /= fPrice + fAi * 100.0 * fRate / fFreq;\n"
+"    y -= 1.0;\n"
+"    y *= fFreq / fDSCi;\n"
+"    return y;\n"
+"}\n";
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 91705cf00446f62a9dc9b169bc9c941d10d72964
Author: mulei <mulei at multicorewareinc.com>
Date:   Wed Nov 6 13:19:50 2013 +0800

    GPU Calc: unit test cases for ODDLPRICE
    
    Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-67 BUG
    
    Change-Id: I1f55cf6c24f6454a933c2431724340c3ef4021e2
    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/financial/Oddlprice.xls b/sc/qa/unit/data/xls/opencl/financial/Oddlprice.xls
new file mode 100644
index 0000000..052d9c4
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/financial/Oddlprice.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index e6ecedd..e4b284d 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -158,6 +158,7 @@ public:
     void testFinancialIPMTFormula();
     void testStatisticalFormulaConfidence();
     void testStatisticalFormulaIntercept();
+    void testFinacialODDLPRICEFormula();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -245,6 +246,7 @@ public:
     CPPUNIT_TEST(testFinancialIPMTFormula);
     CPPUNIT_TEST(testStatisticalFormulaConfidence);
     CPPUNIT_TEST(testStatisticalFormulaIntercept);
+    CPPUNIT_TEST(testFinacialODDLPRICEFormula);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1371,6 +1373,28 @@ void ScOpenclTest::testFinacialDollarfrFormula()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-67]
+void ScOpenclTest::testFinacialODDLPRICEFormula()
+{
+    if (!detectOpenCLDevice())
+        return;
+    ScDocShellRef xDocSh = loadDoc("opencl/financial/Oddlprice.", XLS);
+    ScDocument *pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/financial/Oddlprice.", XLS);
+    ScDocument *pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    for (SCROW i = 1; i <= 10; ++i)
+    {
+        double fLibre = pDoc->GetValue(ScAddress(8, i, 0));
+        double fExcel = pDocRes->GetValue(ScAddress(8, i, 0));
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+    }
+    xDocSh->DoClose();
+    xDocShRes->DoClose();
+}
 //[AMLOEXT-71]
 void ScOpenclTest::testFinacialDISCFormula()
 {
commit ca02aea02a9a88cc306e125b5dc503a640d4037a
Author: mulei <mulei at multicorewareinc.com>
Date:   Wed Nov 6 13:31:22 2013 +0800

    GPU Calc: implemented for ODDLPRICE
    
    AMLOEXT-67 FIX
    
    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 d25a14c..fa89cc7 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1289,6 +1289,12 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                     mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],
                         new OpXirr));
                 }
+                else if ( !(pChild->GetExternal().compareTo(OUString(
+                    "com.sun.star.sheet.addin.Analysis.getOddlprice"))))
+                {
+                    mvSubArguments.push_back(SoPHelper(ts,
+                        ft->Children[i], new OpOddlprice));
+                }
                 break;
             default:
                 throw UnhandledToken(pChild, "unhandled opcode");
diff --git a/sc/source/core/opencl/op_financial.cxx b/sc/source/core/opencl/op_financial.cxx
index 9c9ada4..21a8f47 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -2655,6 +2655,138 @@ void OpPrice::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "return tmp;\n";
     ss << "}";
 }
+void OpOddlprice::BinInlineFun(std::set<std::string>& decls,
+     std::set<std::string>& funs)
+{
+    decls.insert(GetOddlpriceDecl);decls.insert(GetDiffDateDecl);
+    decls.insert(GetYearDiffDecl);decls.insert(IsLeapYearDecl);
+    decls.insert(GetNullDateDecl);decls.insert(DateToDaysDecl);
+    decls.insert(DaysToDateDecl);decls.insert(DaysInMonthDecl);
+    decls.insert(GetYearFracDecl);
+    funs.insert(GetOddlprice);funs.insert(GetDiffDate);
+    funs.insert(GetYearDiff);funs.insert(IsLeapYear);
+    funs.insert(GetNullDate);funs.insert(DaysInMonth);
+    funs.insert(DaysToDate);funs.insert(DateToDays);
+    funs.insert(GetYearFrac);
+}
+void OpOddlprice::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 tmp0=0;\n";
+    ss <<"    double tmp1=0;\n";
+    ss <<"    double tmp2=0;\n";
+    ss <<"    double tmp3=0;\n";
+    ss <<"    double tmp4=0;\n";
+    ss <<"    double tmp5=0;\n";
+    ss <<"    double tmp6=0;\n";
+    ss <<"    double tmp7=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)
+        {
+#ifdef  ISNAN
+            const formula::SingleVectorRefToken* pSVR =
+            dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
+            ss << "    if (gid0 < " << pSVR->GetArrayLength() << "){\n";
+#else
+            nItems += 1;
+#endif
+        }
+        else if (pCur->GetType() == formula::svDouble)
+        {
+#ifdef  ISNAN
+            ss << "{\n";
+#endif
+            nItems += 1;
+        }
+        else
+        {
+#ifdef  ISNAN
+#endif
+            nItems += 1;
+        }
+#ifdef  ISNAN
+        if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
+        {
+            ss << "        if (isNan(";
+            ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss << "))\n";
+            ss << "            tmp"<<i<<"= 0;\n";
+            ss << "        else\n";
+            ss << "            tmp"<<i<<"=";
+            ss <<vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss << ";\n";
+            ss <<"    }\n";
+        }
+        else
+        {
+            ss << "        tmp"<<i<<"=";
+            ss <<vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss <<";\n";
+        }
+#else
+    ss << "        tmp"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
+    ss <<";\n";
+#endif
+    }
+    ss <<"    int nNullDate = GetNullDate();\n";
+    ss <<"    tmp = GetOddlprice(nNullDate,tmp0,tmp1,";
+    ss <<"tmp2,tmp3,tmp4,tmp5,tmp6,tmp7);\n";
+    ss <<"    return tmp;\n";
+    ss <<"}";
+}
 void OpNPER::GenSlidingWindowFunction(std::stringstream &ss,
       const std::string sSymName, SubArguments &vSubArguments)
 {
diff --git a/sc/source/core/opencl/op_financial.hxx b/sc/source/core/opencl/op_financial.hxx
index 423eefd..6c886f9 100644
--- a/sc/source/core/opencl/op_financial.hxx
+++ b/sc/source/core/opencl/op_financial.hxx
@@ -342,6 +342,15 @@ public:
         const std::string sSymName, SubArguments &vSubArguments);
     virtual std::string BinFuncName(void) const { return "NPER"; }
 };
+class OpOddlprice: 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 "Oddlprice"; }
+};
 class OpPPMT: public Normal
 {
 public:
diff --git a/sc/source/core/opencl/opinlinefun_finacial.cxx b/sc/source/core/opencl/opinlinefun_finacial.cxx
index e366047..5e51470 100644
--- a/sc/source/core/opencl/opinlinefun_finacial.cxx
+++ b/sc/source/core/opencl/opinlinefun_finacial.cxx
@@ -1132,6 +1132,27 @@ std::string VDBImplement=
 "    return result;\n"
 "}\n";
 
+std::string GetOddlpriceDecl=
+"double GetOddlprice( int nNullDate, int nSettle, int nMat, int nLastCoup,\n"
+"    double fRate, double fYield, double fRedemp, int nFreq, int nBase );\n";
+
+std::string GetOddlprice=
+"double GetOddlprice( int nNullDate, int nSettle, int nMat, int nLastCoup,\n"
+"    double fRate, double fYield, double fRedemp, int nFreq, int nBase )\n"
+"{\n"
+"    double   fFreq =  nFreq ;\n"
+"    double   fDCi = GetYearFrac( nNullDate, nLastCoup,"
+"nMat, nBase ) * fFreq;\n"
+"    double   fDSCi = GetYearFrac( nNullDate, nSettle,"
+"nMat, nBase ) * fFreq;\n"
+"    double   fAi = GetYearFrac( nNullDate, nLastCoup,"
+"nSettle, nBase ) * fFreq;\n"
+"    double   p = fRedemp + fDCi * 100.0 * fRate / fFreq;\n"
+"    p /= fDSCi * fYield / fFreq + 1.0;\n"
+"    p -= fAi * 100.0 * fRate / fFreq;\n"
+"    return p;\n"
+"}\n";
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 5fffe218705d74ce83d5cf37b95051f2aa8c560d
Author: mingli ju <mingli at multicorewareinc.com>
Date:   Wed Nov 6 12:55:43 2013 +0800

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

diff --git a/sc/qa/unit/data/xls/opencl/statistical/Intercept.xls b/sc/qa/unit/data/xls/opencl/statistical/Intercept.xls
new file mode 100644
index 0000000..7a5c588
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/statistical/Intercept.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index c1cad6e..e6ecedd 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -157,6 +157,7 @@ public:
     void testStatisticalFormulaPhi();
     void testFinancialIPMTFormula();
     void testStatisticalFormulaConfidence();
+    void testStatisticalFormulaIntercept();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -243,6 +244,7 @@ public:
     CPPUNIT_TEST(testStatisticalFormulaPhi);
     CPPUNIT_TEST(testFinancialIPMTFormula);
     CPPUNIT_TEST(testStatisticalFormulaConfidence);
+    CPPUNIT_TEST(testStatisticalFormulaIntercept);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1607,6 +1609,29 @@ void ScOpenclTest::testFinacialXNPVFormula()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-93]
+void ScOpenclTest::testStatisticalFormulaIntercept()
+{
+    if (!detectOpenCLDevice())
+        return;
+
+    ScDocShellRef xDocSh = loadDoc("opencl/statistical/Intercept.", XLS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/statistical/Intercept.", XLS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    for (SCROW i = 1; i <= 19; ++i)
+    {
+        double fLibre = pDoc->GetValue(ScAddress(2,i,0));
+        double fExcel = pDocRes->GetValue(ScAddress(2,i,0));
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+    }
+    xDocSh->DoClose();
+    xDocShRes->DoClose();
+}
 //[AMLOEXT-98]
 void ScOpenclTest::testFinancialAmordegrcFormula()
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 33d1ead..2a71c96 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1395,6 +1395,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocPhi:
             case ocZinsZ:
             case ocConfidence:
+            case ocIntercept:
             // Don't change the state.
             break;
             default:
commit 8a04420ec7df2543713f8541be0c4ace8e06aca9
Author: mingli <mingli at multicorewareinc.com>
Date:   Wed Nov 6 13:07:59 2013 +0800

    GPU Calc: implemented for INTERCEPT
    
    AMLOEXT-93 FIX
    
    Change-Id: Iec88fa93b875f41596ff92622e64f01f8e967319
    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 c488269..d25a14c 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1132,6 +1132,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 mvSubArguments.push_back(SoPHelper(ts,
                          ft->Children[i], new OpConfidence));
                 break;
+            case ocIntercept:
+                mvSubArguments.push_back(SoPHelper(ts,
+                         ft->Children[i], new OpIntercept));
+                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 2900cca..01e0795 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -1858,6 +1858,104 @@ void OpKurt:: GenSlidingWindowFunction(std::stringstream &ss,
         ss<< "    return tmp;\n";
         ss<< "}";
 }
+void OpIntercept::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();
+    FormulaToken *pCur1 = vSubArguments[1]->GetFormulaToken();
+    assert(pCur1);
+    const formula::DoubleVectorRefToken* pCurDVR1 =
+        dynamic_cast<const formula::DoubleVectorRefToken *>(pCur1);
+    size_t nCurWindowSize1 = pCurDVR1->GetRefRowSize();
+    ss << "\ndouble " << sSymName;
+    ss << "_"<< BinFuncName() <<"( ";
+    for (unsigned i = 0; i < vSubArguments.size(); i++)
+    {
+        if (i)
+            ss << ",";
+        vSubArguments[i]->GenSlidingWindowDecl(ss);
+    }
+    ss << ") {\n";
+    ss << "    int gid0 = get_global_id(0);\n";
+    ss << "    double fSumX = 0.0;\n";
+    ss << "    double fSumY = 0.0;\n";
+    ss << "    double fSumDeltaXDeltaY = 0.0;\n";
+    ss << "    double fSumSqrDeltaX = 0.0;\n";
+    ss << "    int length="<<nCurWindowSize;
+    ss << ";\n";
+    ss << "    int length1= "<<nCurWindowSize1;
+    ss << ";\n";
+    ss << "    if(length!=length1)\n";
+    ss << "        return 0;\n";
+    ss << "    double tmp = 0;\n";
+    ss << "    for (int i = 0; i <" << nCurWindowSize << "; i++)\n";
+    ss << "    {\n";
+    ss << "        double arg0 = ";
+    ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+    ss << ";\n";
+    ss << "        double arg1 = ";
+    ss << vSubArguments[1]->GenSlidingWindowDeclRef();
+    ss << ";\n";
+#ifdef ISNAN
+    ss << "        if(isNan(arg0)||((gid0+i)>=";
+    ss << pCurDVR->GetArrayLength();
+    ss << "))\n";
+    ss << "        {\n";
+    ss << "            length--;\n";
+    ss << "            continue;\n";
+    ss << "        }\n";
+#endif
+#ifdef ISNAN
+    ss << "        if(isNan(arg1)||((gid0+i)>=";
+    ss << pCurDVR1->GetArrayLength();
+    ss << "))\n";
+    ss << "        {\n";
+    ss << "            length--;\n";
+    ss << "            continue;\n";
+    ss << "        }\n";
+#endif
+    ss << "        fSumY+=arg0;\n";
+    ss << "        fSumX+=arg1;\n";
+    ss << "    }\n";
+    ss <<"    double fMeanX = fSumX / length;\n";
+    ss <<"    double fMeanY = fSumY / length;\n";
+    ss << "    for (int i = 0; i <" << nCurWindowSize << "; i++)\n";
+    ss << "    {\n";
+    ss << "        double arg0 = ";
+    ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+    ss << ";\n";
+    ss << "        double arg1 = ";
+    ss << vSubArguments[1]->GenSlidingWindowDeclRef();
+    ss << ";\n";
+#ifdef ISNAN
+    ss << "        if(isNan(arg0)||((gid0+i)>=";
+    ss << pCurDVR->GetArrayLength();
+    ss << "))\n";
+    ss << "        {\n";
+    ss << "            continue;\n";
+    ss << "        }\n";
+#endif
+#ifdef ISNAN
+    ss << "        if(isNan(arg1)||((gid0+i)>=";
+    ss <<pCurDVR1->GetArrayLength();
+    ss <<"))\n";
+    ss << "        {";
+    ss << "            continue;\n";
+    ss << "        }\n";
+#endif
+    ss << "        fSumDeltaXDeltaY+=(arg1 - fMeanX) * (arg0 - fMeanY);";
+    ss << ";\n";
+    ss << "        fSumSqrDeltaX+=(arg1 - fMeanX) * (arg1 - fMeanX);\n";
+    ss << "    }\n";
+    ss << "    tmp = fMeanY - fSumDeltaXDeltaY / fSumSqrDeltaX";
+    ss << "* fMeanX;\n";
+    ss << "    return tmp;\n";
+        ss << "}";
+}
 }}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/opencl/op_statistical.hxx b/sc/source/core/opencl/op_statistical.hxx
index 452a159..1803e08 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -185,6 +185,13 @@ public:
 
     virtual std::string BinFuncName(void) const { return "Confidence"; }
 };
+class OpIntercept: public Normal
+{
+public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+            const std::string sSymName, SubArguments &vSubArguments);
+    virtual std::string BinFuncName(void) const { return "Intercept"; }
+};
 }}
 
 #endif
commit 62fb90731cfe887f69d131cc109da8a78afdd983
Author: xinjiang <xinjiang at multicorewareinc.com>
Date:   Wed Nov 6 12:43:21 2013 +0800

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

diff --git a/sc/qa/unit/data/xls/opencl/statistical/Confidence.xls b/sc/qa/unit/data/xls/opencl/statistical/Confidence.xls
new file mode 100644
index 0000000..6bd3847
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/statistical/Confidence.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index f0d7616..c1cad6e 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -156,6 +156,7 @@ public:
     void testStatisticalFormulaPermutation();
     void testStatisticalFormulaPhi();
     void testFinancialIPMTFormula();
+    void testStatisticalFormulaConfidence();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -241,6 +242,7 @@ public:
     CPPUNIT_TEST(testStatisticalFormulaPermutation);
     CPPUNIT_TEST(testStatisticalFormulaPhi);
     CPPUNIT_TEST(testFinancialIPMTFormula);
+    CPPUNIT_TEST(testStatisticalFormulaConfidence);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -2506,6 +2508,31 @@ void ScOpenclTest:: testFinancialXirrFormula()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-140]
+void ScOpenclTest::testStatisticalFormulaConfidence()
+{
+    if (!detectOpenCLDevice())
+        return;
+
+    ScDocShellRef xDocSh = loadDoc("opencl/statistical/Confidence.", XLS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+
+    ScDocShellRef xDocShRes = loadDoc("opencl/statistical/Confidence.", XLS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    // Check the results of formula cells in the shared formula range.
+    for (SCROW i = 0; i <= 9; ++i)
+    {
+        double fLibre = pDoc->GetValue(ScAddress(3,i,0));
+        double fExcel = pDocRes->GetValue(ScAddress(3,i,0));
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+    }
+    xDocSh->DoClose();
+    xDocShRes->DoClose();
+}
 ScOpenclTest::ScOpenclTest()
       : ScBootstrapFixture( "/sc/qa/unit/data" )
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 1a89f5e..33d1ead 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1394,6 +1394,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocVariationen2:
             case ocPhi:
             case ocZinsZ:
+            case ocConfidence:
             // Don't change the state.
             break;
             default:
commit 86e76ea24f3f01b9b0b4860f26d462b6ddaa0f2d
Author: xinjiang <xinjiang at multicorewareinc.com>
Date:   Wed Nov 6 12:50:30 2013 +0800

    GPU Calc: implemented for CONFIDENCE
    
    AMLOEXT-140 FIX
    
    Change-Id: I570bf1606358e9cd2b90d1e53e665d4110e4286d
    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 1cf28e7..c488269 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1128,6 +1128,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 mvSubArguments.push_back(SoPHelper(ts,
                          ft->Children[i],new OpIPMT));
                  break;
+            case ocConfidence:
+                mvSubArguments.push_back(SoPHelper(ts,
+                         ft->Children[i], new OpConfidence));
+                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 f27ab46..2900cca 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -17,6 +17,7 @@
 #include "interpre.hxx"
 #include "formula/vectortoken.hxx"
 #include <sstream>
+#include "opinlinefun_statistical.cxx"
 
 using namespace formula;
 
@@ -853,6 +854,87 @@ void OpHarMean::GenSlidingWindowFunction(
     ss << "}";
 }
 
+void OpConfidence::BinInlineFun(std::set<std::string>& decls,
+    std::set<std::string>& funs)
+{
+    decls.insert(gaussinvDecl);
+    funs.insert(gaussinv);
+}
+
+void OpConfidence::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 = " << GetBottom() <<";\n";
+    ss << "    int gid0 = get_global_id(0);\n";
+    ss << "    double alpha = " << GetBottom() <<";\n";
+    ss << "    double sigma = " << GetBottom() <<";\n";
+    ss << "    double size = " << GetBottom() <<";\n";
+#ifdef  ISNAN
+    FormulaToken* tmpCur0 = vSubArguments[0]->GetFormulaToken();
+    const formula::SingleVectorRefToken* tmpCurDVR0= dynamic_cast<const
+    formula::SingleVectorRefToken* >(tmpCur0);
+    FormulaToken* tmpCur1 = vSubArguments[1]->GetFormulaToken();
+    const formula::SingleVectorRefToken* tmpCurDVR1= dynamic_cast<const
+    formula::SingleVectorRefToken* >(tmpCur1);
+    FormulaToken* tmpCur2 = vSubArguments[2]->GetFormulaToken();
+    const formula::SingleVectorRefToken* tmpCurDVR2= dynamic_cast<const
+    formula::SingleVectorRefToken* >(tmpCur2);
+    ss << "    int buffer_alpha_len = ";
+    ss << tmpCurDVR0->GetArrayLength();
+    ss << ";\n";
+    ss << "    int buffer_sigma_len = ";
+    ss << tmpCurDVR1->GetArrayLength();
+    ss << ";\n";
+    ss << "    int buffer_size_len = ";
+    ss << tmpCurDVR2->GetArrayLength();
+    ss << ";\n";
+#endif
+#ifdef  ISNAN
+    ss << "    if((gid0)>=buffer_alpha_len || isNan(";
+    ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+    ss << "))\n";
+    ss << "        alpha = 0;\n    else\n";
+#endif
+    ss << "        alpha = ";
+    ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+    ss << ";\n";
+#ifdef  ISNAN
+    ss << "    if((gid0)>=buffer_sigma_len || isNan(";
+    ss << vSubArguments[1]->GenSlidingWindowDeclRef();
+    ss << "))\n";
+    ss << "        sigma = 0;\n    else\n";
+#endif
+    ss << "        sigma = ";
+    ss << vSubArguments[1]->GenSlidingWindowDeclRef();
+    ss << ";\n";
+#ifdef  ISNAN
+    ss << "    if((gid0)>=buffer_size_len || isNan(";
+    ss << vSubArguments[2]->GenSlidingWindowDeclRef();
+    ss << "))\n";
+    ss << "        size = 0;\n    else\n";
+#endif
+    ss << "        size = ";
+    ss << vSubArguments[2]->GenSlidingWindowDeclRef();
+    ss << ";\n";
+    ss << "    double rn = floor(size);\n";
+    ss << "    if(sigma <= 0.0 || alpha <= 0.0 || alpha >= 1.0";
+    ss << "|| rn < 1.0)\n";
+    ss << "        tmp = -DBL_MAX;\n";
+    ss << "    else\n";
+    ss << "        tmp = gaussinv(1.0 - alpha / 2.0) * sigma / sqrt( rn );\n";
+    ss << "    return tmp;\n";
+    ss << "}";
+}
+
 void OpRsq::GenSlidingWindowFunction(
     std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments)
 {
diff --git a/sc/source/core/opencl/op_statistical.hxx b/sc/source/core/opencl/op_statistical.hxx
index c91e0f4..452a159 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -172,6 +172,19 @@ class OpVariationen2:public Normal{
             const std::string sSymName, SubArguments &vSubArguments);
     virtual std::string BinFuncName(void) const { return "OpVariationen2";}
 };
+
+class OpConfidence: public Normal
+{
+public:
+    virtual std::string GetBottom(void) { return "0"; }
+
+    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 "Confidence"; }
+};
 }}
 
 #endif
diff --git a/sc/source/core/opencl/opinlinefun_statistical.cxx b/sc/source/core/opencl/opinlinefun_statistical.cxx
new file mode 100644
index 0000000..f2ba0ab
--- /dev/null
+++ b/sc/source/core/opencl/opinlinefun_statistical.cxx
@@ -0,0 +1,183 @@
+/* -*- 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_OPINLINFUN_statistical
+#define SC_OPENCL_OPINLINFUN_statistical
+std::string fBigInvDecl ="#define fBigInv  2.22045e-016\n";
+std::string fLogDblMaxDecl ="#define fLogDblMax  log(1.79769e+308)\n";
+std::string fHalfMachEpsDecl ="#define fHalfMachEps  0.5*2.22045e-016\n";
+std::string fMaxGammaArgumentDecl =
+"#define fMaxGammaArgument  171.624376956302\n";
+
+std::string gaussinvDecl = "double gaussinv(double x);\n";
+std::string gaussinv =
+"double gaussinv(double x)\n"
+"{\n"
+"    double q,t,z;\n"
+"    q=x-0.5;\n"
+"    if(fabs(q)<=.425)\n"
+"    {\n"
+"        t=0.180625-q*q;\n"
+"        z=\n"
+"            q*\n"
+"            (\n"
+"            (\n"
+"            (\n"
+"            (\n"
+"            (\n"
+"            (\n"
+"            (\n"
+"            t*2509.0809287301226727+33430.575583588128105\n"
+"            )\n"
+"            *t+67265.770927008700853\n"
+"            )\n"
+"            *t+45921.953931549871457\n"
+"            )\n"
+"            *t+13731.693765509461125\n"
+"            )\n"
+"            *t+1971.5909503065514427\n"
+"            )\n"
+"            *t+133.14166789178437745\n"
+"            )\n"
+"            *t+3.387132872796366608\n"
+"            )\n"
+"            /\n"
+"            (\n"
+"            (\n"
+"            (\n"
+"            (\n"
+"            (\n"
+"            (\n"
+"            (\n"
+"            t*5226.495278852854561+28729.085735721942674\n"
+"            )\n"
+"            *t+39307.89580009271061\n"
+"            )\n"
+"            *t+21213.794301586595867\n"
+"            )\n"
+"            *t+5394.1960214247511077\n"
+"            )\n"
+"            *t+687.1870074920579083\n"
+"            )\n"
+"            *t+42.313330701600911252\n"
+"            )\n"
+"            *t+1.0\n"
+"            );\n"
+"    }\n"
+"    else\n"
+"    {\n"
+"        if(q>0) t=1-x;\n"
+"        else        t=x;\n"
+"        t=sqrt(-log(t));\n"
+"        if(t<=5.0)\n"
+"        {\n"
+"            t+=-1.6;\n"
+"            z=\n"
+"                (\n"
+"                (\n"
+"                (\n"
+"                (\n"
+"                (\n"
+"                (\n"
+"                (\n"
+"                t*7.7454501427834140764e-4+0.0227238449892691845833\n"
+"                )\n"
+"                *t+0.24178072517745061177\n"
+"                )\n"
+"                *t+1.27045825245236838258\n"
+"                )\n"
+"                *t+3.64784832476320460504\n"
+"                )\n"
+"                *t+5.7694972214606914055\n"
+"                )\n"
+"                *t+4.6303378461565452959\n"
+"                )\n"
+"                *t+1.42343711074968357734\n"
+"                )\n"
+"                /\n"
+"                (\n"
+"                (\n"
+"                (\n"
+"                (\n"
+"                (\n"
+"                (\n"
+"                (\n"
+"                t*1.05075007164441684324e-9+5.475938084995344946e-4\n"
+"                )\n"
+"                *t+0.0151986665636164571966\n"
+"                )\n"
+"                *t+0.14810397642748007459\n"
+"                )\n"
+"                *t+0.68976733498510000455\n"
+"                )\n"
+"                *t+1.6763848301838038494\n"
+"                )\n"
+"                *t+2.05319162663775882187\n"
+"                )\n"
+"                *t+1.0\n"
+"                );\n"
+"        }\n"
+"        else\n"
+"        {\n"
+"            t+=-5.0;\n"
+"            z=\n"
+"                (\n"
+"                (\n"
+"                (\n"
+"                (\n"
+"                (\n"
+"                (\n"
+"                (\n"
+"                t*2.01033439929228813265e-7+2.71155556874348757815e-5\n"
+"                )\n"
+"                *t+0.0012426609473880784386\n"
+"                )\n"
+"                *t+0.026532189526576123093\n"
+"                )\n"
+"                *t+0.29656057182850489123\n"
+"                )\n"
+"                *t+1.7848265399172913358\n"
+"                )\n"
+"                *t+5.4637849111641143699\n"
+"                )\n"
+"                *t+6.6579046435011037772\n"
+"                )\n"
+"                /\n"
+"                (\n"
+"                (\n"
+"                (\n"
+"                (\n"
+"                (\n"
+"                (\n"
+"                (\n"
+"                t*2.04426310338993978564e-15+1.4215117583164458887e-7\n"
+"                )\n"
+"                *t+1.8463183175100546818e-5\n"
+"                )\n"
+"                *t+7.868691311456132591e-4\n"
+"                )\n"
+"                *t+0.0148753612908506148525\n"
+"                )\n"
+"                *t+0.13692988092273580531\n"
+"                )\n"
+"                *t+0.59983220655588793769\n"
+"                )\n"
+"                *t+1.0\n"
+"                );\n"
+"        }\n"
+"        if(q<0.0) z=-z;\n"
+"    }\n"
+"    return z;\n"
+"}\n";
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+
commit 6e1de4bf6e1a6284ee743d4da7d43f5f96cf1096
Author: xinjiang <xinjiang at multicorewareinc.com>
Date:   Wed Nov 6 12:28:28 2013 +0800

    GPU Calc: unit test cases for IPMT
    
    Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-134 BUG
    
    Change-Id: I14df6a7b3ecb874d88c97419bd394846655f048a
    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/financial/IPMT.xls b/sc/qa/unit/data/xls/opencl/financial/IPMT.xls
new file mode 100644
index 0000000..dbb6e51
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/financial/IPMT.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index afc2c7e..f0d7616 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -155,6 +155,7 @@ public:
     void testStatisticalFormulaPermut();
     void testStatisticalFormulaPermutation();
     void testStatisticalFormulaPhi();
+    void testFinancialIPMTFormula();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -239,6 +240,7 @@ public:
     CPPUNIT_TEST(testStatisticalFormulaPermut);
     CPPUNIT_TEST(testStatisticalFormulaPermutation);
     CPPUNIT_TEST(testStatisticalFormulaPhi);
+    CPPUNIT_TEST(testFinancialIPMTFormula);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -2454,6 +2456,28 @@ void ScOpenclTest:: testFinancialVDBFormula()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-134]
+void ScOpenclTest:: testFinancialIPMTFormula()
+{
+    if (!detectOpenCLDevice())
+        return;
+    ScDocShellRef xDocSh = loadDoc("opencl/financial/IPMT.", XLS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/financial/IPMT.", XLS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    for (SCROW i = 0; i <= 9; ++i)
+    {
+        double fLibre = pDoc->GetValue(ScAddress(6, i, 0));
+        double fExcel = pDocRes->GetValue(ScAddress(6, i, 0));
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+    }
+    xDocSh->DoClose();
+    xDocShRes->DoClose();
+}
   //[AMLOEXT-137]
 void ScOpenclTest:: testFinancialXirrFormula()
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index d6ad095..1a89f5e 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1393,6 +1393,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocVariationen:
             case ocVariationen2:
             case ocPhi:
+            case ocZinsZ:
             // Don't change the state.
             break;
             default:
commit 99d3acc8a498cdb7e28dec8045ab5d395da7c7a9
Author: xinjiang <xinjiang at multicorewareinc.com>
Date:   Wed Nov 6 12:35:21 2013 +0800

    GPU Calc: implemented for IPMT
    
    AMLOEXT-134 FIX
    
    Change-Id: I5b5c9c484d7d1b585d0bd20f5a08ef033701e08e
    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 1e59df8..1cf28e7 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1124,6 +1124,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 mvSubArguments.push_back(SoPHelper(ts,
                          ft->Children[i],new OpPhi));
                 break;
+            case ocZinsZ:
+                mvSubArguments.push_back(SoPHelper(ts,
+                         ft->Children[i],new OpIPMT));
+                 break;
             case ocExternal:
                 if ( !(pChild->GetExternal().compareTo(OUString(
                     "com.sun.star.sheet.addin.Analysis.getEffect"))))
diff --git a/sc/source/core/opencl/op_financial.cxx b/sc/source/core/opencl/op_financial.cxx
index 4afb9b6..9c9ada4 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -537,6 +537,84 @@ void OpFV::GenSlidingWindowFunction(std::stringstream& ss,
     ss << "    return tmp;\n";
     ss << "}";
 }
+
+void OpIPMT::BinInlineFun(std::set<std::string>& decls,
+    std::set<std::string>& funs)
+{
+    decls.insert(GetZwDecl);
+    funs.insert(GetZw);
+}
+
+void OpIPMT::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 = " << GetBottom() << ";\n";
+    ss << "    int gid0 = get_global_id(0);\n";
+    ss << "    double arg0 = " << GetBottom() << ";\n";
+    ss << "    double arg1 = " << GetBottom() << ";\n";
+    ss << "    double arg2 = " << GetBottom() << ";\n";
+    ss << "    double arg3 = " << GetBottom() << ";\n";
+    ss << "    double arg4 = " << GetBottom() << ";\n";
+    ss << "    double arg5 = " << GetBottom() << ";\n";
+    unsigned j = vSubArguments.size();
+    while (j--)
+        {
+        FormulaToken* pCur = vSubArguments[j]->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() << " || isNan(";
+            ss << vSubArguments[j]->GenSlidingWindowDeclRef();
+            ss << "))\n";
+            ss << "        arg" << j << " = " <<GetBottom() << ";\n";
+            ss << "    else\n";
+#endif
+            ss << "        arg" << j << " = ";
+            ss << vSubArguments[j]->GenSlidingWindowDeclRef();
+            ss << ";\n";
+            }
+        }
+    ss << "    double pmt ;\n";
+    ss << "    if(arg0 == 0.0)\n";
+    ss << "        return 0;\n";
+    ss << "    double temp1 = 0;\n";
+    ss << "    double abl = pow(1.0 + arg0, arg2);\n";
+    ss << "    temp1 -= arg4;\n";
+    ss << "    temp1 -= arg3 * abl;\n";
+    ss << "    pmt = temp1 / (1.0 + arg0 * arg5) /";
+    ss << " ( (abl - 1.0) / arg0);\n";
+    ss << "    double temp = pow( 1 + arg0, arg1 - 2);\n";
+    ss << "    if(arg1 == 1.0)\n";
+    ss << "    {\n";
+    ss << "        if(arg5 > 0.0)\n";
+    ss << "            tmp = 0.0;\n";
+    ss << "        else\n";
+    ss << "            tmp = -arg3;\n";
+    ss << "    }\n";
+    ss << "    else\n";
+    ss << "    {\n";
+    ss << "        if(arg5 > 0.0)\n";
+    ss << "            tmp = GetZw(arg0, arg1 - 2.0, pmt, arg3, 1.0)";
+    ss << " - pmt;\n";
+    ss << "        else\n";
+    ss << "            tmp = GetZw(arg0, arg1 - 1.0, pmt, arg3, 0.0);\n";
+    ss << "    }\n";
+    ss << "    tmp = tmp * arg0;\n";
+    ss << "    return tmp;\n";
+    ss << "}";
+}
 void OpISPMT::GenSlidingWindowFunction(std::stringstream& ss,
     const std::string sSymName, SubArguments& vSubArguments)
 {
diff --git a/sc/source/core/opencl/op_financial.hxx b/sc/source/core/opencl/op_financial.hxx
index 4283dd9..423eefd 100644
--- a/sc/source/core/opencl/op_financial.hxx
+++ b/sc/source/core/opencl/op_financial.hxx
@@ -100,6 +100,20 @@ public:
         return "FV"; }
 };
 
+class OpIPMT: public Normal
+{
+public:
+    virtual std::string GetBottom(void) { return "0"; }
+
+    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 "IPMT"; }
+};
+
 class OpISPMT: public Normal
 {
 public:
commit 709762a13e539a45c37cd25008fb7b22a99d3fa8
Author: hongyu zhong <hongyu at multicorewareinc.com>
Date:   Wed Nov 6 12:04:29 2013 +0800

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

diff --git a/sc/qa/unit/data/xls/opencl/statistical/Phi.xls b/sc/qa/unit/data/xls/opencl/statistical/Phi.xls
new file mode 100644
index 0000000..6555289
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/statistical/Phi.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index dda81ac..afc2c7e 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -154,6 +154,7 @@ public:
     void testStatisticalFormulaNormsinv();
     void testStatisticalFormulaPermut();
     void testStatisticalFormulaPermutation();
+    void testStatisticalFormulaPhi();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -237,6 +238,7 @@ public:
     CPPUNIT_TEST(testStatisticalFormulaNormsinv);
     CPPUNIT_TEST(testStatisticalFormulaPermut);
     CPPUNIT_TEST(testStatisticalFormulaPermutation);
+    CPPUNIT_TEST(testStatisticalFormulaPhi);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1760,6 +1762,29 @@ void ScOpenclTest::testStatisticalFormulaPermutation()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-105]
+void ScOpenclTest::testStatisticalFormulaPhi()
+{
+    if (!detectOpenCLDevice())
+        return;
+    ScDocShellRef xDocSh = loadDoc("opencl/statistical/Phi.",XLS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/statistical/Phi.",XLS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    // Check the results of formula cells in the shared formula range.
+    for (SCROW i = 1; i <= 19; ++i)
+    {
+        double fLibre = pDoc->GetValue(ScAddress(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-108]
 void ScOpenclTest::testFinacialNPERFormula()
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 0d1cdab..d6ad095 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1392,6 +1392,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocSNormInv:
             case ocVariationen:
             case ocVariationen2:
+            case ocPhi:
             // Don't change the state.
             break;
             default:
commit c79083ef236b0ce2bd87bdb7b03f5c83aee23393
Author: hongyu zhong <hongyu at multicorewareinc.com>
Date:   Wed Nov 6 12:20:45 2013 +0800

    GPU Calc: implemented for PHI
    
    AMLOEXT-105 FIX
    
    Change-Id: I41648a58937ca2cb77fe06f23543bcb9c9480332
    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 8f999ac..1e59df8 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1120,6 +1120,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 mvSubArguments.push_back(SoPHelper(ts,
                          ft->Children[i],new OpVariationen2));
                 break;
+            case ocPhi:
+                mvSubArguments.push_back(SoPHelper(ts,
+                         ft->Children[i],new OpPhi));
+                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 2b77d2a..f27ab46 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -1169,6 +1169,43 @@ void OpVariationen2::GenSlidingWindowFunction(
     ss << "    return tmp;\n";
     ss << "}\n";
 }
+void OpPhi::GenSlidingWindowFunction(
+    std::stringstream &ss,const std::string sSymName,
+    SubArguments &vSubArguments)
+{
+    ss << "\ndouble " << sSymName;
+    ss << "_"<< BinFuncName() <<"(";
+    for (unsigned i = 0; i < vSubArguments.size(); i++)
+    {
+        if (i)
+            ss << ",";
+        vSubArguments[i]->GenSlidingWindowDecl(ss);
+    }
+    ss << ")\n";
+    ss << "{\n";
+    ss << "    double x;\n";
+    ss << "    int gid0=get_global_id(0);\n";
+#ifdef ISNAN
+    FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken();
+    const formula::SingleVectorRefToken*tmpCurDVR0= dynamic_cast<const
+    formula::SingleVectorRefToken *>(tmpCur0);
+    ss << "    int buffer_x_len = ";
+    ss << tmpCurDVR0->GetArrayLength();
+    ss << ";\n";
+#endif
+#ifdef ISNAN
+    ss <<"    if((gid0)>=buffer_x_len || isNan(";
+    ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+    ss <<"))\n";
+    ss <<"        x = 0;\n";
+    ss <<"    else \n";
+#endif
+    ss << "       x = "<<vSubArguments[0]->GenSlidingWindowDeclRef();
+    ss << ";\n";
+    ss << "    double tmp = 0.39894228040143268 * exp(-(x * x) / 2.0);\n";
+    ss << "     return tmp;\n";
+    ss << "}\n";
+}
 void OpNorminv::GenSlidingWindowFunction(
     std::stringstream &ss,const std::string sSymName,
     SubArguments &vSubArguments)
diff --git a/sc/source/core/opencl/op_statistical.hxx b/sc/source/core/opencl/op_statistical.hxx
index dc47fc1..c91e0f4 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -147,6 +147,12 @@ class OpNormsinv:public Normal{
             const std::string sSymName, SubArguments &vSubArguments);
      virtual std::string BinFuncName(void) const { return "OpNormsinv"; }
 };
+class OpPhi:public Normal{
+    public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+            const std::string sSymName, SubArguments &vSubArguments);
+    virtual std::string BinFuncName(void) const { return "OpPhi"; }
+};
 class OpKurt: public Normal
 {
 public:
commit 9a3b3b11c82435373dccd7faca29fa4bbd248fa3
Author: hongyu zhong <hongyu at multicorewareinc.com>
Date:   Wed Nov 6 11:53:39 2013 +0800

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

diff --git a/sc/qa/unit/data/xls/opencl/statistical/Permutation.xls b/sc/qa/unit/data/xls/opencl/statistical/Permutation.xls
new file mode 100644
index 0000000..c5527b4
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/statistical/Permutation.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 4a897ff..dda81ac 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -153,6 +153,7 @@ public:
     void testStatisticalFormulaNorminv();
     void testStatisticalFormulaNormsinv();
     void testStatisticalFormulaPermut();
+    void testStatisticalFormulaPermutation();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -235,6 +236,7 @@ public:
     CPPUNIT_TEST(testStatisticalFormulaNorminv);
     CPPUNIT_TEST(testStatisticalFormulaNormsinv);
     CPPUNIT_TEST(testStatisticalFormulaPermut);
+    CPPUNIT_TEST(testStatisticalFormulaPermutation);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1735,6 +1737,29 @@ void ScOpenclTest::testStatisticalFormulaPermut()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-104]
+void ScOpenclTest::testStatisticalFormulaPermutation()
+{
+    if (!detectOpenCLDevice())
+        return;
+    ScDocShellRef xDocSh = loadDoc("opencl/statistical/Permutation.",XLS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/statistical/Permutation.",XLS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    // Check the results of formula cells in the shared formula range.
+    for (SCROW i = 1; i <= 9; ++i)
+    {
+        double fLibre = pDoc->GetValue(ScAddress(2,i,0));
+        double fExcel = pDocRes->GetValue(ScAddress(2,i,0));
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+    }
+    xDocSh->DoClose();
+    xDocShRes->DoClose();
+}
 //[AMLOEXT-108]
 void ScOpenclTest::testFinacialNPERFormula()
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 67ce69c..0d1cdab 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1391,6 +1391,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocNormInv:
             case ocSNormInv:
             case ocVariationen:
+            case ocVariationen2:
             // Don't change the state.
             break;
             default:
commit e581934cf1c75e214982d662c85a67c820be184f
Author: hongyu zhong <hongyu at multicorewareinc.com>
Date:   Wed Nov 6 11:56:43 2013 +0800

    GPU Calc: implemented for PERMUTATION
    
    AMLOEXT-104 FIX
    
    Change-Id: I00b273c7995d0f34c7126d159d6d38b6b993f7c7
    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 1ffe370..8f999ac 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1116,6 +1116,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 mvSubArguments.push_back(SoPHelper(ts,
                          ft->Children[i],new OpVariationen));
                 break;
+            case ocVariationen2:
+                mvSubArguments.push_back(SoPHelper(ts,
+                         ft->Children[i],new OpVariationen2));
+                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 cdd892b..2b77d2a 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -1119,6 +1119,56 @@ void OpVariationen::GenSlidingWindowFunction(
     ss << "   return tmp;\n";
     ss << "}\n";
 }
+void OpVariationen2::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 inA;\n";
+    ss <<"    double inB;\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);
+    ss << "int buffer_fIna_len = ";
+    ss << tmpCurDVR0->GetArrayLength();
+    ss << ";\n";
+    ss << "    int buffer_fInb_len = ";
+    ss << tmpCurDVR1->GetArrayLength();
+    ss << ";\n";
+#endif
+#ifdef ISNAN
+    ss << "    if((gid0)>=buffer_fIna_len || isNan(";
+    ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+    ss << "))\n";
+    ss << "    inA = 0;\nelse \n";
+#endif
+    ss << "        inA = "<<vSubArguments[0]->GenSlidingWindowDeclRef();
+    ss << ";\n";
+#ifdef ISNAN
+    ss << "if((gid0)>=buffer_fInb_len || isNan(";
+    ss << vSubArguments[1]->GenSlidingWindowDeclRef();
+    ss << "))\n";
+    ss << "inB = 0;\nelse \n";
+#endif
+    ss << "    inB = "<<vSubArguments[1]->GenSlidingWindowDeclRef();
+    ss << ";\n";
+    ss << "    double tmp = pow(inA,inB);\n";
+    ss << "    return tmp;\n";
+    ss << "}\n";
+}
 void OpNorminv::GenSlidingWindowFunction(
     std::stringstream &ss,const std::string sSymName,
     SubArguments &vSubArguments)
diff --git a/sc/source/core/opencl/op_statistical.hxx b/sc/source/core/opencl/op_statistical.hxx
index 2491c6d..dc47fc1 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -160,6 +160,12 @@ class OpVariationen:public Normal{
             const std::string sSymName, SubArguments &vSubArguments);
     virtual std::string BinFuncName(void) const { return "OpVariationen"; }
 };
+class OpVariationen2:public Normal{
+    public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+            const std::string sSymName, SubArguments &vSubArguments);
+    virtual std::string BinFuncName(void) const { return "OpVariationen2";}
+};
 }}
 
 #endif
commit 1508b80670866e745c3c9a62e8b7fb149fd3a2cd
Author: hongyu zhong <hongyu at multicorewareinc.com>
Date:   Wed Nov 6 11:34:41 2013 +0800

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

diff --git a/sc/qa/unit/data/xls/opencl/statistical/Permut.xls b/sc/qa/unit/data/xls/opencl/statistical/Permut.xls
new file mode 100644
index 0000000..9338528
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/statistical/Permut.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index d088929..4a897ff 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -152,6 +152,7 @@ public:
     void testStatisticalFormulaNormsdist();
     void testStatisticalFormulaNorminv();
     void testStatisticalFormulaNormsinv();
+    void testStatisticalFormulaPermut();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -233,6 +234,7 @@ public:
     CPPUNIT_TEST(testStatisticalFormulaNormsdist);
     CPPUNIT_TEST(testStatisticalFormulaNorminv);
     CPPUNIT_TEST(testStatisticalFormulaNormsinv);
+    CPPUNIT_TEST(testStatisticalFormulaPermut);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1710,7 +1712,29 @@ void ScOpenclTest::testStatisticalFormulaNormsdist()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
-
+//[AMLOEXT-103]
+void ScOpenclTest::testStatisticalFormulaPermut()
+{
+    if (!detectOpenCLDevice())
+        return;
+    ScDocShellRef xDocSh = loadDoc("opencl/statistical/Permut.",XLS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/statistical/Permut.",XLS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    // Check the results of formula cells in the shared formula range.
+    for (SCROW i = 1; i <= 19; ++i)
+    {
+        double fLibre = pDoc->GetValue(ScAddress(2,i,0));
+        double fExcel = pDocRes->GetValue(ScAddress(2,i,0));
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+    }
+    xDocSh->DoClose();
+    xDocShRes->DoClose();
+}
 //[AMLOEXT-108]
 void ScOpenclTest::testFinacialNPERFormula()
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index e5e3fd8..67ce69c 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1390,6 +1390,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocStdNormDist:
             case ocNormInv:
             case ocSNormInv:
+            case ocVariationen:
             // Don't change the state.
             break;
             default:
commit 7357ef8bc6f2de7fb221af319b7d1d55c910c2e1
Author: hongyu zhong <hongyu at multicorewareinc.com>
Date:   Wed Nov 6 11:44:46 2013 +0800

    GPU Calc: implemented for PERMUT
    
    AMLOEXT-103 FIX
    
    Change-Id: Id96ce91b8d7cb5c2949e52e5ace48c66dc5b8639
    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 f3b5a77..1ffe370 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list