correction equation in sci_daskr 38/15938/11
Sylvain GENIN [Thu, 12 Feb 2015 08:31:03 +0000 (09:31 +0100)]
test_run differential_equations daskr

Change-Id: Ie4bd0feadfb44f3a646123866d6430588efbf8c2

scilab/modules/differential_equations/includes/checkodeerror.hxx [moved from scilab/modules/differential_equations/includes/checkodeerror.h with 76% similarity]
scilab/modules/differential_equations/sci_gateway/cpp/sci_daskr.cpp
scilab/modules/differential_equations/sci_gateway/cpp/sci_dasrt.cpp
scilab/modules/differential_equations/sci_gateway/cpp/sci_dassl.cpp
scilab/modules/differential_equations/sci_gateway/cpp/sci_impl.cpp
scilab/modules/differential_equations/sci_gateway/cpp/sci_ode.cpp
scilab/modules/differential_equations/sci_gateway/cpp/sci_odedc.cpp
scilab/modules/differential_equations/src/cpp/checkodeerror.cpp
scilab/modules/differential_equations/src/cpp/differentialequationfunctions.cpp

 *
 */
 /*--------------------------------------------------------------------------*/
+#ifndef __CHECK_ODE_ERROR__
+#define __CHECK_ODE_ERROR__
+
+#include <string>
 #include "dynlib_differential_equations.h"
 
 DIFFERENTIAL_EQUATIONS_IMPEXP int checkOdeError(int meth, int istate);
-DIFFERENTIAL_EQUATIONS_IMPEXP int checkDasslError(int idid);
+DIFFERENTIAL_EQUATIONS_IMPEXP int checkError(int idid, std::string strName);
+
+#endif // __CHECK_ODE_ERROR__
index 5a76344..4ef2f0b 100644 (file)
@@ -20,6 +20,7 @@
 #include "callable.hxx"
 #include "differentialequationfunctions.hxx"
 #include "runvisitor.hxx"
+#include "checkodeerror.hxx"
 
 extern "C"
 {
@@ -29,7 +30,6 @@ extern "C"
 #include "sciprint.h"
 #include "scifunctions.h"
 #include "elem_common.h"
-#include "checkodeerror.h"
 }
 
 /*--------------------------------------------------------------------------*/
@@ -618,7 +618,7 @@ types::Function::ReturnValue sci_daskr(types::typed_list &in, int _iRetCount, ty
                 if (pDblTemp->getSize() == 0)
                 {
                     // maxl and kmp need default values
-                    maxl = min(5, pDblX0->getSize());
+                    maxl = min(5, pDblX0->getRows());
                     kmp = maxl;
                 }
                 else
@@ -753,7 +753,7 @@ types::Function::ReturnValue sci_daskr(types::typed_list &in, int _iRetCount, ty
     //compute itol and set the tolerances rtol and atol.
     double* rtol    = NULL;
     double* atol    = NULL;
-    double rpar[2]  = {0, 0};
+    double rpar[2] = {0, 0 };
     int ipar[30];
     memset(ipar, 0x00, 30 * sizeof(int));
 
@@ -839,7 +839,7 @@ types::Function::ReturnValue sci_daskr(types::typed_list &in, int _iRetCount, ty
         // LENWP is the length ot the rwork segment containing
         // the matrix elements of the preconditioner P
 
-        LENWP = 7 * pDblX0->getRows();
+        LENWP = pDblX0->getRows() * pDblX0->getRows();
         rworksize += (maxord + 5) * pDblX0->getRows() + 3 * ng
                      + (maxl + 3 + min(1, maxl - kmp)) * pDblX0->getRows()
                      + (maxl + 3) * maxl + 1 + LENWP;
@@ -862,7 +862,7 @@ types::Function::ReturnValue sci_daskr(types::typed_list &in, int _iRetCount, ty
         // LENIWP is the length ot the iwork segment containing
         // the matrix indexes of the preconditioner P
         // (compressed sparse row format)
-        LENIWP = 25 * pDblX0->getRows() + 1;
+        LENIWP = 2 * pDblX0->getRows() * pDblX0->getRows();
         iworksize += LENIWP;
     }
 
@@ -964,7 +964,7 @@ types::Function::ReturnValue sci_daskr(types::typed_list &in, int _iRetCount, ty
         ipar[3] = 2;
         ipar[4] = 1;
         rpar[0] = 0.005;
-        rpar[1] = 0.005;
+        rpar[1] = 0.05;
     }
 
     if (info[15] == 1)
@@ -1046,7 +1046,7 @@ types::Function::ReturnValue sci_daskr(types::typed_list &in, int _iRetCount, ty
             }
 
             // use the same error function that dasrt
-            iret = checkDasslError(idid);
+            iret = checkError(idid, "daskr");
             if (iret == 1) // error
             {
                 Scierror(999, _("%s: ddaskr return with state %d.\n"), "daskr", ididtmp);
index 5548e9a..d33b2f2 100644 (file)
@@ -19,6 +19,7 @@
 #include "callable.hxx"
 #include "differentialequationfunctions.hxx"
 #include "runvisitor.hxx"
+#include "checkodeerror.hxx"
 
 extern "C"
 {
@@ -28,7 +29,6 @@ extern "C"
 #include "sciprint.h"
 #include "scifunctions.h"
 #include "elem_common.h"
-#include "checkodeerror.h"
 }
 
 /*--------------------------------------------------------------------------*/
@@ -744,7 +744,7 @@ types::Function::ReturnValue sci_dasrt(types::typed_list &in, int _iRetCount, ty
         try
         {
             C2F(ddasrt)(dassl_f, YSize, &t0, pdYData, pdYdotData, &t, info, rtol, atol, &idid, rwork, &rworksize, iwork, &iworksize, &rpar, &ipar, dassl_jac, dasrt_g, &ng, root);
-            iret = checkDasslError(idid);
+            iret = checkError(idid, "dasrt");
             if (iret == 1) // error
             {
                 Scierror(999, _("%s: ddasrt return with state %d.\n"), "dasrt", idid);
index 6709a36..5e1c103 100644 (file)
@@ -19,6 +19,7 @@
 #include "callable.hxx"
 #include "differentialequationfunctions.hxx"
 #include "runvisitor.hxx"
+#include "checkodeerror.hxx"
 
 extern "C"
 {
@@ -28,9 +29,7 @@ extern "C"
 #include "sciprint.h"
 #include "scifunctions.h"
 #include "elem_common.h"
-#include "checkodeerror.h"
 #include "xerhlt.h"
-
 }
 
 /*--------------------------------------------------------------------------*/
@@ -681,7 +680,7 @@ types::Function::ReturnValue sci_dassl(types::typed_list &in, int _iRetCount, ty
         {
             C2F(dassl)(dassl_f, YSize, &t0, pdYData, pdYdotData, &t, info, rtol, atol, &idid, rwork, &rworksize, iwork, &iworksize, &rpar, &ipar, dassl_jac);
 
-            iret = checkDasslError(idid);
+            iret = checkError(idid, "dassl");
             if (iret == 1) // error
             {
                 Scierror(999, _("%s: dassl return with state %d.\n"), "dassl", idid);
index f093740..78ebdce 100644 (file)
@@ -19,6 +19,7 @@
 #include "callable.hxx"
 #include "differentialequationfunctions.hxx"
 #include "runvisitor.hxx"
+#include "checkodeerror.hxx"
 
 extern "C"
 {
@@ -27,7 +28,6 @@ extern "C"
 #include "Scierror.h"
 #include "scifunctions.h"
 #include "elem_common.h"
-#include "checkodeerror.h"
 #include "sciprint.h"
 #include "common_structure.h"
 }
@@ -575,7 +575,7 @@ types::Function::ReturnValue sci_impl(types::typed_list &in, int _iRetCount, typ
         nyh = C2F(ls0001).nyh;
     }
 
-    rworkSize = 20 + nyh * (maxord + 1) + 3 * *YSize + *YSize * *YSize + 2;
+    rworkSize = 20 + nyh * (maxord + 1) + 3 * *YSize + *YSize **YSize + 2;
     iworkSize = 20 + *YSize;
 
     rwSize = rworkSize + dStructTabSize;
index 8230a80..bf35d2a 100644 (file)
@@ -20,6 +20,7 @@
 #include "differentialequationfunctions.hxx"
 #include "runvisitor.hxx"
 #include "context.hxx"
+#include "checkodeerror.hxx"
 
 extern "C"
 {
@@ -30,7 +31,6 @@ extern "C"
 #include "configvariable_interface.h"
 #include "sciprint.h"
 #include "common_structure.h"
-#include "checkodeerror.h"
 #include "sci_malloc.h"
 }
 /*--------------------------------------------------------------------------*/
index a60d8e1..ea0dc3e 100644 (file)
@@ -20,6 +20,7 @@
 #include "differentialequationfunctions.hxx"
 #include "runvisitor.hxx"
 #include "context.hxx"
+#include "checkodeerror.hxx"
 
 extern "C"
 {
@@ -31,7 +32,6 @@ extern "C"
 #include "sciprint.h"
 #include "common_structure.h"
 #include "scifunctions.h"
-#include "checkodeerror.h"
 }
 
 /*--------------------------------------------------------------------------*/
index 4598bd2..8e904a1 100644 (file)
 */
 /*--------------------------------------------------------------------------*/
 
-extern "C" {
-#include "checkodeerror.h"
+#include "checkodeerror.hxx"
+
+extern "C"
+{
 #include "sciprint.h"
 #include "localization.h"
 #include "configvariable_interface.h"
@@ -155,7 +157,7 @@ int checkOdeError(int meth, int istate)
     return 0;
 }
 
-int checkDasslError(int idid)
+int checkError(int idid, std::string strName)
 {
     switch (idid)
     {
@@ -281,7 +283,7 @@ int checkDasslError(int idid)
             //when invalid input is detected.
             if (getWarningMode())
             {
-                sciprint(_("encountered trouble.\n"));
+                sciprint(_("%s encountered trouble.\n"), strName.c_str());
             }
             return 2;
         }
index 41456ab..e027a76 100644 (file)
@@ -2635,10 +2635,16 @@ void DifferentialEquationFunctions::callDasslMacroF(double* t, double* y, double
 
     C2F(dcopy)(&m_odeYRows, pDblOutDelta->get(), &one, delta, &one);
     *ires = (int)pDblOutIres->get(0);
+
     if (out[0]->isDeletable())
     {
         delete out[0];
     }
+
+    if (out[1]->isDeletable())
+    {
+        delete out[1];
+    }
 }
 
 void DifferentialEquationFunctions::callDasslMacroJac(double* t, double* y, double* ydot, double* pd, double* cj, double* rpar, int* ipar)
@@ -2909,6 +2915,8 @@ void DifferentialEquationFunctions::callDaskrMacroPjac(double* res, int* ires, i
     }
 
     out[0]->IncreaseRef();
+    out[1]->IncreaseRef();
+    out[2]->IncreaseRef();
 
     pDblNeq->DecreaseRef();
     if (pDblNeq->isDeletable())
@@ -3060,12 +3068,12 @@ void DifferentialEquationFunctions::callDaskrMacroPsol(int* neq, double* t, doub
     ast::ExecVisitor execFunc;
 
     // input arguments psol(R, iR, b)
-    types::Double* pDblR = new types::Double(1, *neq **neq);
+    types::Double* pDblR = new types::Double(*neq **neq, 1);
     pDblR->set(wp);
     pDblR->IncreaseRef();
     in.push_back(pDblR);
 
-    types::Double* pDblIR = new types::Double(1, 2 * *neq **neq);
+    types::Double* pDblIR = new types::Double(*neq **neq, 2);
     double* pdblIR = pDblIR->get();
     for (int i = 0; i < pDblIR->getSize(); i++)
     {
@@ -3074,7 +3082,7 @@ void DifferentialEquationFunctions::callDaskrMacroPsol(int* neq, double* t, doub
     pDblIR->IncreaseRef();
     in.push_back(pDblIR);
 
-    types::Double* pDblB = new types::Double(1, *neq);
+    types::Double* pDblB = new types::Double(*neq, 1);
     pDblB->set(b);
     pDblB->IncreaseRef();
     in.push_back(pDblB);
@@ -3104,6 +3112,7 @@ void DifferentialEquationFunctions::callDaskrMacroPsol(int* neq, double* t, doub
     }
 
     out[0]->IncreaseRef();
+    out[1]->IncreaseRef();
 
     // free input arguments
     pDblR->DecreaseRef();