# HG changeset patch # User jwe # Date 1026928807 0 # Node ID d4091aff646824a027216345164244d1c365eab1 # Parent 98107d72871cc30ad8f78d5fc3e0847b3203165f [project @ 2002-07-17 18:00:06 by jwe] diff -r 98107d72871c -r d4091aff6468 liboctave/ChangeLog --- a/liboctave/ChangeLog Wed Jul 17 16:22:05 2002 +0000 +++ b/liboctave/ChangeLog Wed Jul 17 18:00:07 2002 +0000 @@ -1,3 +1,12 @@ +2002-07-17 John W. Eaton + + * base-de.h (base_diff_eqn::istate): New data member. + (base_diff_eqn::integration_state): New member function. + * LSODE.h, LSODE.cc, ODESSA.h, ODESSA.cc: Delete corresponding + data members and functions. + * DASPK.h, DASRT.h, DASSL.h: Delete idid data member. + * DASPK.cc, DASRT.cc, DASSL.cc: Use istate instead of idid. + 2002-07-16 John W. Eaton * base-de.h (base_diff_eqn::stop_time, diff -r 98107d72871c -r d4091aff6468 liboctave/DASPK.cc --- a/liboctave/DASPK.cc Wed Jul 17 16:22:05 2002 +0000 +++ b/liboctave/DASPK.cc Wed Jul 17 18:00:07 2002 +0000 @@ -269,7 +269,7 @@ // again: F77_XFCN (ddaspk, DDASPK, (ddaspk_f, n, t, px, pxdot, tout, pinfo, - rel_tol, abs_tol, idid, prwork, lrw, + rel_tol, abs_tol, istate, prwork, lrw, piwork, liw, dummy, idummy, ddaspk_j, ddaspk_psol)); @@ -280,7 +280,7 @@ } else { - switch (idid) + switch (istate) { case 1: // A step was successfully taken in intermediate-output // mode. The code has not yet reached TOUT. @@ -330,7 +330,8 @@ default: integration_error = true; (*current_liboctave_error_handler) - ("unrecognized value of idid (= %d) returned from ddaspk", idid); + ("unrecognized value of istate (= %d) returned from ddaspk", + istate); break; } } @@ -494,7 +495,7 @@ { std::string retval; - switch (idid) + switch (istate) { case 1: retval = "a step was successfully taken in intermediate-output mode."; diff -r 98107d72871c -r d4091aff6468 liboctave/DASPK.h --- a/liboctave/DASPK.h Wed Jul 17 16:22:05 2002 +0000 +++ b/liboctave/DASPK.h Wed Jul 17 18:00:07 2002 +0000 @@ -138,7 +138,6 @@ int n; int liw; int lrw; - int idid; int sanity_checked; Array info; Array iwork; diff -r 98107d72871c -r d4091aff6468 liboctave/DASRT.cc --- a/liboctave/DASRT.cc Wed Jul 17 16:22:05 2002 +0000 +++ b/liboctave/DASRT.cc Wed Jul 17 18:00:07 2002 +0000 @@ -316,7 +316,7 @@ int *idummy = 0; F77_XFCN (ddasrt, DASRT, (ddasrt_f, n, t, px, pxdot, tout, pinfo, - &rel_tol, &abs_tol, idid, prwork, lrw, + &rel_tol, &abs_tol, istate, prwork, lrw, piwork, liw, dummy, idummy, ddasrt_j, ddasrt_g, ng, pjroot)); @@ -327,7 +327,7 @@ } else { - switch (idid) + switch (istate) { case 1: // A step was successfully taken in intermediate-output // mode. The code has not yet reached TOUT. @@ -371,7 +371,8 @@ default: integration_error = true; (*current_liboctave_error_handler) - ("unrecognized value of idid (= %d) returned from ddasrt", idid); + ("unrecognized value of istate (= %d) returned from ddasrt", + istate); break; } } @@ -409,7 +410,7 @@ return retval; } - if (idid == 4) + if (istate == 4) t_out(j) = t; else t_out(j) = tout(j); @@ -420,7 +421,7 @@ xdot_out(j,i) = xdot(i); } - if (idid == 4) + if (istate == 4) { x_out.resize (j+1, n); xdot_out.resize (j+1, n); @@ -513,7 +514,7 @@ return retval; } - if (idid == 4) + if (istate == 4) t_out = t; if (save_output) @@ -526,7 +527,7 @@ t_outs(i_out-1) = t_out; - if (idid == 4) + if (istate == 4) { x_out.resize (i_out, n); xdot_out.resize (i_out, n); @@ -558,7 +559,7 @@ { std::string retval; - switch (idid) + switch (istate) { case 1: retval = "a step was successfully taken in intermediate-output mode."; diff -r 98107d72871c -r d4091aff6468 liboctave/DASRT.h --- a/liboctave/DASRT.h Wed Jul 17 16:22:05 2002 +0000 +++ b/liboctave/DASRT.h Wed Jul 17 18:00:07 2002 +0000 @@ -180,7 +180,6 @@ int liw; int lrw; - int idid; int n; int ng; diff -r 98107d72871c -r d4091aff6468 liboctave/DASSL.cc --- a/liboctave/DASSL.cc Wed Jul 17 16:22:05 2002 +0000 +++ b/liboctave/DASSL.cc Wed Jul 17 18:00:07 2002 +0000 @@ -243,7 +243,7 @@ // again: F77_XFCN (ddassl, DDASSL, (ddassl_f, n, t, px, pxdot, tout, pinfo, - rel_tol, abs_tol, idid, prwork, lrw, + rel_tol, abs_tol, istate, prwork, lrw, piwork, liw, dummy, idummy, ddassl_j)); if (f77_exception_encountered) @@ -253,7 +253,7 @@ } else { - switch (idid) + switch (istate) { case 1: // A step was successfully taken in intermediate-output // mode. The code has not yet reached TOUT. @@ -294,7 +294,8 @@ default: integration_error = true; (*current_liboctave_error_handler) - ("unrecognized value of idid (= %d) returned from ddassl", idid); + ("unrecognized value of istate (= %d) returned from ddassl", + istate); break; } } @@ -458,7 +459,7 @@ { std::string retval; - switch (idid) + switch (istate) { case 1: retval = "a step was successfully taken in intermediate-output mode."; diff -r 98107d72871c -r d4091aff6468 liboctave/DASSL.h --- a/liboctave/DASSL.h Wed Jul 17 16:22:05 2002 +0000 +++ b/liboctave/DASSL.h Wed Jul 17 18:00:07 2002 +0000 @@ -138,7 +138,6 @@ int n; int liw; int lrw; - int idid; bool sanity_checked; Array info; Array iwork; diff -r 98107d72871c -r d4091aff6468 liboctave/LSODE.cc --- a/liboctave/LSODE.cc Wed Jul 17 16:22:05 2002 +0000 +++ b/liboctave/LSODE.cc Wed Jul 17 18:00:07 2002 +0000 @@ -70,7 +70,6 @@ { n = size (); - istate = 1; itask = 1; iopt = 0; @@ -82,7 +81,6 @@ { n = size (); - istate = 1; itask = 1; iopt = 0; diff -r 98107d72871c -r d4091aff6468 liboctave/LSODE.h --- a/liboctave/LSODE.h Wed Jul 17 16:22:05 2002 +0000 +++ b/liboctave/LSODE.h Wed Jul 17 18:00:07 2002 +0000 @@ -159,8 +159,6 @@ Matrix do_integrate (const ColumnVector& tout, const ColumnVector& tcrit); - int integration_state (void) const { return istate; } - std::string error_message (void) const; private: @@ -169,7 +167,6 @@ int method_flag; Array iwork; Array rwork; - int istate; int itask; int iopt; int liw; diff -r 98107d72871c -r d4091aff6468 liboctave/ODESSA.cc --- a/liboctave/ODESSA.cc Wed Jul 17 16:22:05 2002 +0000 +++ b/liboctave/ODESSA.cc Wed Jul 17 18:00:07 2002 +0000 @@ -178,7 +178,6 @@ iopt.resize(4); - istate = 1; itask = 1; iopt(0) = 0; isopt = 0; @@ -197,7 +196,6 @@ n = size (); iopt.resize(4); - istate = 1; itask = 1; iopt(0) = 0; isopt = 0; @@ -238,7 +236,6 @@ npar = theta.length (); iopt.resize(4); - istate = 1; itask = 1; iopt(0) = 0; isopt = 1; @@ -429,10 +426,10 @@ const double *pabs_tol = abs_tol.fortran_vec (); - F77_XFCN (odessa, ODESSA, (odessa_f,odessa_b,pneq,py,ppar,t, tout, - itol,rel_tol,pabs_tol,itask,istate, - piopt,prwork,lrw,piwork,liw,odessa_j, - method_flag)); + F77_XFCN (odessa, ODESSA, (odessa_f, odessa_b, pneq, py, ppar, t, + tout, itol, rel_tol, pabs_tol, itask, + istate, piopt, prwork, lrw, piwork, liw, + odessa_j, method_flag)); if (f77_exception_encountered) { diff -r 98107d72871c -r d4091aff6468 liboctave/ODESSA.h --- a/liboctave/ODESSA.h Wed Jul 17 16:22:05 2002 +0000 +++ b/liboctave/ODESSA.h Wed Jul 17 18:00:07 2002 +0000 @@ -197,8 +197,6 @@ ODESSA_result integrate (const ColumnVector& tout, const ColumnVector& tcrit); - int integration_state (void) const { return istate; } - std::string error_message (void) const; private: @@ -212,7 +210,6 @@ int method_flag; Array iwork; Array rwork; - int istate; int itask; Array iopt; int isopt; diff -r 98107d72871c -r d4091aff6468 liboctave/base-de.h --- a/liboctave/base-de.h Wed Jul 17 16:22:05 2002 +0000 +++ b/liboctave/base-de.h Wed Jul 17 18:00:07 2002 +0000 @@ -35,15 +35,15 @@ base_diff_eqn (void) : x (), t (0.0), stop_time (0.0), stop_time_set (false), - restart (true), integration_error (false) { } + restart (true), integration_error (false), istate (0) { } base_diff_eqn (const ColumnVector& xx, double tt) : x (xx), t (tt), stop_time (0.0), stop_time_set (false), - restart (true), integration_error (false) { } + restart (true), integration_error (false), istate (0) { } base_diff_eqn (const base_diff_eqn& a) : x (a.x), t (a.t), stop_time (0.0), stop_time_set (false), - restart (true), integration_error (false) { } + restart (true), integration_error (false), istate (0) { } virtual ~base_diff_eqn (void) { } @@ -57,6 +57,7 @@ stop_time_set = a.stop_time_set; restart = a.restart; integration_error = a.integration_error; + istate = a.istate; } return *this; @@ -67,6 +68,7 @@ x = x0; t = t0; integration_error = false; + istate = 0; force_restart (); } @@ -88,6 +90,8 @@ bool integration_ok (void) const { return ! integration_error; } + int integration_state (void) const { return istate; } + virtual std::string error_message (void) const = 0; protected: @@ -103,6 +107,8 @@ bool restart; bool integration_error; + + int istate; }; #endif diff -r 98107d72871c -r d4091aff6468 src/ChangeLog --- a/src/ChangeLog Wed Jul 17 16:22:05 2002 +0000 +++ b/src/ChangeLog Wed Jul 17 18:00:07 2002 +0000 @@ -1,3 +1,12 @@ +2002-07-17 John W. Eaton + + * DLD-FUNCTIONS/daspk.cc (Fdaspk): Also return istate and error + message. Only generate error if user is not at least requesting + the istate output. + * DLD-FUNCTIONS/dasrt.cc (Fdasrt): Likewise. + * DLD-FUNCTIONS/dassl.cc (Fdassl): Likewise. + * DLD-FUNCTIONS/lsode.cc (Fodessa): Likewise. + 2002-07-16 John W. Eaton * DLD-FUNCTIONS/dasrt.cc (Fdasrt): No need to find ng here. diff -r 98107d72871c -r d4091aff6468 src/DLD-FUNCTIONS/daspk.cc --- a/src/DLD-FUNCTIONS/daspk.cc Wed Jul 17 16:22:05 2002 +0000 +++ b/src/DLD-FUNCTIONS/daspk.cc Wed Jul 17 18:00:07 2002 +0000 @@ -138,7 +138,7 @@ } \ while (0) -DEFUN_DLD (daspk, args, , +DEFUN_DLD (daspk, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {[@var{x}, @var{xdot}] =} daspk (@var{fcn}, @var{x0}, @var{xdot0}, @var{t}, @var{t_crit})\n\ Return a matrix of states and their first derivatives with respect to\n\ @@ -247,10 +247,24 @@ if (! error_state) { - retval.resize (2); + std::string msg = dae.error_message (); + + retval(3) = msg; + retval(2) = static_cast (dae.integration_state ()); - retval(0) = output; - retval(1) = deriv_output; + if (dae.integration_ok ()) + { + retval(1) = deriv_output; + retval(0) = output; + } + else + { + retval(1) = Matrix (); + retval(0) = Matrix (); + + if (nargout < 3) + error ("daspk: %s", msg.c_str ()); + } } } else diff -r 98107d72871c -r d4091aff6468 src/DLD-FUNCTIONS/dasrt.cc --- a/src/DLD-FUNCTIONS/dasrt.cc Wed Jul 17 16:22:05 2002 +0000 +++ b/src/DLD-FUNCTIONS/dasrt.cc Wed Jul 17 18:00:07 2002 +0000 @@ -234,7 +234,7 @@ } \ while (0) -DEFUN_DLD (dasrt, args, , +DEFUN_DLD (dasrt, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {[@var{x}, @var{xdot}, @var{t}] =} dasrt (@var{fj} [, @var{g}], @var{x_0}, @var{xdot_0}, @var{t_out} [, @var{t_crit}])\n\ Solve a system of differential/algebraic equations with functional\n\ @@ -442,9 +442,6 @@ dae.copy (dasrt_opts); - if (error_state) - DASRT_ABORT1 ("something is wrong"); - if (crit_times_set) output = dae.integrate (out_times, crit_times); else @@ -452,14 +449,26 @@ if (! error_state) { - retval(2) = output.times (); - retval(1) = output.deriv (); - retval(0) = output.state (); - } - else - { - DASRT_ABORT1("something wicked has occurred!"); - // print_usage ("dasrt"); + std::string msg = dae.error_message (); + + retval(4) = msg; + retval(3) = static_cast (dae.integration_state ()); + + if (dae.integration_ok ()) + { + retval(2) = output.times (); + retval(1) = output.deriv (); + retval(0) = output.state (); + } + else + { + retval(2) = Matrix (); + retval(1) = Matrix (); + retval(0) = Matrix (); + + if (nargout < 4) + error ("dasrt: %s", msg.c_str ()); + } } unwind_protect::run_frame ("Fdasrt"); diff -r 98107d72871c -r d4091aff6468 src/DLD-FUNCTIONS/dassl.cc --- a/src/DLD-FUNCTIONS/dassl.cc Wed Jul 17 16:22:05 2002 +0000 +++ b/src/DLD-FUNCTIONS/dassl.cc Wed Jul 17 18:00:07 2002 +0000 @@ -352,8 +352,24 @@ if (! error_state) { - retval(1) = deriv_output; - retval(0) = output; + std::string msg = dae.error_message (); + + retval(3) = msg; + retval(2) = static_cast (dae.integration_state ()); + + if (dae.integration_ok ()) + { + retval(1) = deriv_output; + retval(0) = output; + } + else + { + retval(1) = Matrix (); + retval(0) = Matrix (); + + if (nargout < 3) + error ("dassl: %s", msg.c_str ()); + } } } else diff -r 98107d72871c -r d4091aff6468 src/DLD-FUNCTIONS/lsode.cc --- a/src/DLD-FUNCTIONS/lsode.cc Wed Jul 17 16:22:05 2002 +0000 +++ b/src/DLD-FUNCTIONS/lsode.cc Wed Jul 17 18:00:07 2002 +0000 @@ -289,7 +289,9 @@ if (! error_state) { - retval(2) = ode.error_message (); + std::string msg = ode.error_message (); + + retval(2) = msg; retval(1) = static_cast (ode.integration_state ()); if (ode.integration_ok ()) @@ -299,10 +301,7 @@ retval(0) = Matrix (); if (nargout < 2) - { - std::string msg = ode.error_message (); - error ("lsode: %s", msg.c_str ()); - } + error ("lsode: %s", msg.c_str ()); } } } diff -r 98107d72871c -r d4091aff6468 src/DLD-FUNCTIONS/odessa.cc --- a/src/DLD-FUNCTIONS/odessa.cc Wed Jul 17 16:22:05 2002 +0000 +++ b/src/DLD-FUNCTIONS/odessa.cc Wed Jul 17 18:00:07 2002 +0000 @@ -257,7 +257,7 @@ // Everthing is so great above here // -------------------------------- -DEFUN_DLD (odessa, args, , +DEFUN_DLD (odessa, args, nargout, "odessa (\"f\", x_0, theta, sx_0, t_out, t_crit)\n\ \n\ The string \"f\" may be substituted for the vector of strings\n\ @@ -406,47 +406,49 @@ ODESSA_result output; - if (have_parameters) - { - ODESSA dae = ODESSA (state, theta, sensitivity_guess, tzero, func); + ODESSA ode = have_parameters + ? ODESSA (state, theta, sensitivity_guess, tzero, func) + : ODESSA (state, tzero, func); - dae.copy (odessa_opts); + ode.copy (odessa_opts); - if (crit_times_set) - output = dae.integrate (out_times, crit_times); - else - output = dae.integrate (out_times); - } + if (crit_times_set) + output = ode.integrate (out_times, crit_times); else - { - ODESSA dae = ODESSA (state, tzero, func); - - dae.copy (odessa_opts); - - if (crit_times_set) - output = dae.integrate (out_times, crit_times); - else - output = dae.integrate (out_times); - } + output = ode.integrate (out_times); if (! error_state) { - if (have_parameters) + int k = have_parameters ? 3 : 2; + + std::string msg = ode.error_message (); + + retval(k--) = msg; + retval(k--) = static_cast (ode.integration_state ()); + + if (ode.integration_ok ()) { - retval(1) = make_list (output.state_sensitivity ()); + if (have_parameters) + retval(1) = make_list (output.state_sensitivity ()); + + retval(0) = output.state (); } - - retval(0) = output.state (); + else + { + if (have_parameters) + retval(1) = Matrix (); + + retval(0) = Matrix (); + + if ((have_parameters && nargout < 3) || nargout < 2) + error ("odessa: %s", msg.c_str ()); + } } unwind_protect::run_frame ("Fodessa"); return retval; } -// ----------------------------- -// EVERYTHING SWELL BELOW HERE -// ----------------------------- - typedef void (ODESSA_options::*da_set_opt_mf) (const Array&); typedef void (ODESSA_options::*d_set_opt_mf) (double);