# HG changeset patch # User jwe # Date 838244691 0 # Node ID d7592de300ea3816376e75065c659cd423a0e9ab # Parent 95e511896bf5e836cf3f18045dd4303fb2f3d5d8 [project @ 1996-07-24 21:42:44 by jwe] diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +Wed Jul 24 16:39:16 1996 John W. Eaton + + * LSODE.cc (do_integrate): Check to make sure that the state and + derivative vectors are the same size. + Sun Jul 14 17:30:37 1996 John W. Eaton * dMatrix.cc (Matrix::read, Matrix::write): Convert to use diff --git a/liboctave/LSODE.cc b/liboctave/LSODE.cc --- a/liboctave/LSODE.cc +++ b/liboctave/LSODE.cc @@ -71,6 +71,8 @@ liw = 20 + n; lrw = 22 + n * (9 + n); + + sanity_checked = 0; } LSODE::LSODE (const ColumnVector& state, double time, const ODEFunc& f) @@ -91,6 +93,8 @@ liw = 20 + n; lrw = 22 + n * (9 + n); + + sanity_checked = 0; } void @@ -116,7 +120,7 @@ lsode_f (const int& neq, const double& time, double *, double *deriv, int& ierr) { - ColumnVector tmp_deriv (neq); + ColumnVector tmp_deriv; // NOTE: this won't work if LSODE passes copies of the state vector. // In that case we have to create a temporary vector object @@ -198,6 +202,22 @@ user_fun = function (); user_jac = jacobian_function (); + if (! sanity_checked) + { + ColumnVector xdot = (*user_fun) (x, t); + + if (x.length () != xdot.length ()) + { + (*current_liboctave_error_handler) + ("lsode: inconsistent sizes for state and derivative vectors"); + + integration_error = 1; + return retval; + } + + sanity_checked = 1; + } + // Try 5000 steps before giving up. iwork.elem (5) = 5000; diff --git a/liboctave/LSODE.h b/liboctave/LSODE.h --- a/liboctave/LSODE.h +++ b/liboctave/LSODE.h @@ -165,6 +165,7 @@ int liw; int lrw; int working_too_hard; + int sanity_checked; friend int lsode_f (int *neq, double *t, double *y, double *ydot); diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,8 @@ Wed Jul 24 05:08:07 1996 John W. Eaton + * lsode.cc (Flsode): Don't set the return value if an error + occurred during integration. + * file-io.cc (symbols_of_file_io): Redefine values of SEEK_SET, SEEK_CUR, and SEEK_END for Matlab compatibility. * oct-stream.cc (seek): Check for compatible values of ORIGIN arg. diff --git a/src/lsode.cc b/src/lsode.cc --- a/src/lsode.cc +++ b/src/lsode.cc @@ -164,8 +164,12 @@ else output = ode.integrate (out_times); - retval.resize (1); - retval(0) = output; + if (! error_state) + { + retval.resize (1); + retval(0) = output; + } + return retval; }