Mercurial > hg > octave-lyh
changeset 3997:d4091aff6468
[project @ 2002-07-17 18:00:06 by jwe]
author | jwe |
---|---|
date | Wed, 17 Jul 2002 18:00:07 +0000 |
parents | 98107d72871c |
children | f6df65db67f9 |
files | liboctave/ChangeLog liboctave/DASPK.cc liboctave/DASPK.h liboctave/DASRT.cc liboctave/DASRT.h liboctave/DASSL.cc liboctave/DASSL.h liboctave/LSODE.cc liboctave/LSODE.h liboctave/ODESSA.cc liboctave/ODESSA.h liboctave/base-de.h src/ChangeLog src/DLD-FUNCTIONS/daspk.cc src/DLD-FUNCTIONS/dasrt.cc src/DLD-FUNCTIONS/dassl.cc src/DLD-FUNCTIONS/lsode.cc src/DLD-FUNCTIONS/odessa.cc |
diffstat | 18 files changed, 141 insertions(+), 88 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,12 @@ +2002-07-17 John W. Eaton <jwe@bevo.che.wisc.edu> + + * 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 <jwe@bevo.che.wisc.edu> * base-de.h (base_diff_eqn::stop_time,
--- a/liboctave/DASPK.cc +++ b/liboctave/DASPK.cc @@ -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.";
--- a/liboctave/DASPK.h +++ b/liboctave/DASPK.h @@ -138,7 +138,6 @@ int n; int liw; int lrw; - int idid; int sanity_checked; Array<int> info; Array<int> iwork;
--- a/liboctave/DASRT.cc +++ b/liboctave/DASRT.cc @@ -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.";
--- a/liboctave/DASRT.h +++ b/liboctave/DASRT.h @@ -180,7 +180,6 @@ int liw; int lrw; - int idid; int n; int ng;
--- a/liboctave/DASSL.cc +++ b/liboctave/DASSL.cc @@ -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.";
--- a/liboctave/DASSL.h +++ b/liboctave/DASSL.h @@ -138,7 +138,6 @@ int n; int liw; int lrw; - int idid; bool sanity_checked; Array<int> info; Array<int> iwork;
--- a/liboctave/LSODE.cc +++ b/liboctave/LSODE.cc @@ -70,7 +70,6 @@ { n = size (); - istate = 1; itask = 1; iopt = 0; @@ -82,7 +81,6 @@ { n = size (); - istate = 1; itask = 1; iopt = 0;
--- a/liboctave/LSODE.h +++ b/liboctave/LSODE.h @@ -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<int> iwork; Array<double> rwork; - int istate; int itask; int iopt; int liw;
--- a/liboctave/ODESSA.cc +++ b/liboctave/ODESSA.cc @@ -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) {
--- a/liboctave/ODESSA.h +++ b/liboctave/ODESSA.h @@ -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<int> iwork; Array<double> rwork; - int istate; int itask; Array<int> iopt; int isopt;
--- a/liboctave/base-de.h +++ b/liboctave/base-de.h @@ -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
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2002-07-17 John W. Eaton <jwe@bevo.che.wisc.edu> + + * 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 <jwe@bevo.che.wisc.edu> * DLD-FUNCTIONS/dasrt.cc (Fdasrt): No need to find ng here.
--- a/src/DLD-FUNCTIONS/daspk.cc +++ b/src/DLD-FUNCTIONS/daspk.cc @@ -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<double> (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
--- a/src/DLD-FUNCTIONS/dasrt.cc +++ b/src/DLD-FUNCTIONS/dasrt.cc @@ -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<double> (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");
--- a/src/DLD-FUNCTIONS/dassl.cc +++ b/src/DLD-FUNCTIONS/dassl.cc @@ -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<double> (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
--- a/src/DLD-FUNCTIONS/lsode.cc +++ b/src/DLD-FUNCTIONS/lsode.cc @@ -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<double> (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 ()); } } }
--- a/src/DLD-FUNCTIONS/odessa.cc +++ b/src/DLD-FUNCTIONS/odessa.cc @@ -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<double> (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<double>&); typedef void (ODESSA_options::*d_set_opt_mf) (double);