Mercurial > hg > octave-lojdl
changeset 11502:4638800cd660
delete data pointer members from liboctave ODE/DAE classes; make destuctors virtual in ODE/DAE base classes
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 13 Jan 2011 03:16:40 -0500 |
parents | 331fcc41ca23 |
children | b3f511c48b14 |
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/ODES.h |
diffstat | 10 files changed, 121 insertions(+), 94 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,33 @@ +2011-01-13 John W. Eaton <jwe@octave.org> + + * DAE.h (DAE::~DAE): Now virtual. + * DAERT.h (DAERT::~DAERT): Likewise. + * ODE.h (ODE::~ODE): Likewise. + * DAEFunc.h (DAEFunc::~DAEFunc): Likewise. + * DAERTFunc.h (DAEFunc::~DAEFunc): Likewise. + * ODEFunc.h (ODE::~ODE): Likewise. + * ODESFunc.h (ODESFunc::~ODESFunc): Likewise. + + * LSODE.h (class LSODE): Delete pointer data members. + (LSODE::LSODE): Initialize all data members in initialization lists. + * LSODE.cc (LSODE::integrate): Extract pointers to data from + array data members at each call. + + * DASPK.h (class DASPK): Delete pointer data members. + (DASPK::DASPK): Initialize all data members in initialization lists. + * DASPK.cc (DASPK::integrate): Extract pointers to data from + array data members at each call. + + * DASSL.h (class DASSL): Delete pointer data members. + (DASSL::DASSL): Initialize all data members in initialization lists. + * DASSL.cc (DASSL::integrate): Extract pointers to data from + array data members at each call. + + * DASRT.h (class DASRT): Delete pointer data members. + (DASRT::DASRT): Initialize all data members in initialization lists. + * DASRT.cc (DASRT::integrate): Extract pointers to data from + array data members at each call. + 2011-01-13 John W. Eaton <jwe@octave.org> * kpse.cc (struct str_llist_elt, struct cache_entry):
--- a/liboctave/DASPK.cc +++ b/liboctave/DASPK.cc @@ -73,7 +73,8 @@ static octave_idx_type ddaspk_f (const double& time, const double *state, const double *deriv, - const double&, double *delta, octave_idx_type& ires, double *, octave_idx_type *) + const double&, double *delta, octave_idx_type& ires, double *, + octave_idx_type *) { BEGIN_INTERRUPT_WITH_EXCEPTIONS; @@ -171,8 +172,6 @@ for (octave_idx_type i = 0; i < 20; i++) info(i) = 0; - pinfo = info.fortran_vec (); - octave_idx_type n = size (); nn = n; @@ -187,9 +186,6 @@ else info(3) = 0; - px = x.fortran_vec (); - pxdot = xdot.fortran_vec (); - // DAEFunc user_fun = DAEFunc::function (); @@ -240,9 +236,6 @@ iwork.resize (liw, 1); rwork.resize (lrw, 1); - piwork = iwork.fortran_vec (); - prwork = rwork.fortran_vec (); - // DASPK_options abs_tol = absolute_tolerance (); @@ -268,9 +261,6 @@ return retval; } - pabs_tol = abs_tol.fortran_vec (); - prel_tol = rel_tol.fortran_vec (); - double hmax = maximum_step_size (); if (hmax >= 0.0) { @@ -460,8 +450,19 @@ restart = false; } - static double *dummy = 0; - static octave_idx_type *idummy = 0; + double *px = x.fortran_vec (); + double *pxdot = xdot.fortran_vec (); + + octave_idx_type *pinfo = info.fortran_vec (); + + double *prel_tol = rel_tol.fortran_vec (); + double *pabs_tol = abs_tol.fortran_vec (); + + double *prwork = rwork.fortran_vec (); + octave_idx_type *piwork = iwork.fortran_vec (); + + double *dummy = 0; + octave_idx_type *idummy = 0; F77_XFCN (ddaspk, DDASPK, (ddaspk_f, nn, t, px, pxdot, tout, pinfo, prel_tol, pabs_tol, istate, prwork, lrw,
--- a/liboctave/DASPK.h +++ b/liboctave/DASPK.h @@ -35,14 +35,19 @@ { public: - DASPK (void) : DAE (), DASPK_options (), initialized (false) { } + DASPK (void) + : DAE (), DASPK_options (), initialized (false), liw (0), lrw (0), + info (), iwork (), rwork (), abs_tol (), rel_tol () { } DASPK (const ColumnVector& s, double tm, DAEFunc& f) - : DAE (s, tm, f), DASPK_options (), initialized (false) { } + : DAE (s, tm, f), DASPK_options (), initialized (false), liw (0), + lrw (0), info (), iwork (), rwork (), abs_tol (), rel_tol () { } DASPK (const ColumnVector& s, const ColumnVector& deriv, double tm, DAEFunc& f) - : DAE (s, deriv, tm, f), DASPK_options (), initialized (false) { } + : DAE (s, deriv, tm, f), DASPK_options (), initialized (false), + liw (0), lrw (0), info (), iwork (), rwork (), abs_tol (), + rel_tol () { } ~DASPK (void) { } @@ -73,14 +78,6 @@ Array<double> abs_tol; Array<double> rel_tol; - - double *px; - double *pxdot; - double *pabs_tol; - double *prel_tol; - octave_idx_type *pinfo; - octave_idx_type *piwork; - double *prwork; }; #endif
--- a/liboctave/DASRT.cc +++ b/liboctave/DASRT.cc @@ -171,8 +171,6 @@ for (octave_idx_type i = 0; i < 15; i++) info(i) = 0; - pinfo = info.fortran_vec (); - octave_idx_type n = size (); nn = n; @@ -222,12 +220,6 @@ else info(3) = 0; - px = x.fortran_vec (); - pxdot = xdot.fortran_vec (); - - piwork = iwork.fortran_vec (); - prwork = rwork.fortran_vec (); - restart = false; // DAEFunc @@ -265,8 +257,6 @@ jroot.resize (ng, 1, 1); - pjroot = jroot.fortran_vec (); - DAERTFunc::reset = false; // DASRT_options @@ -320,14 +310,24 @@ return; } - pabs_tol = abs_tol.fortran_vec (); - prel_tol = rel_tol.fortran_vec (); - DASRT_options::reset = false; } - static double *dummy = 0; - static octave_idx_type *idummy = 0; + double *px = x.fortran_vec (); + double *pxdot = xdot.fortran_vec (); + + octave_idx_type *pinfo = info.fortran_vec (); + + double *prel_tol = rel_tol.fortran_vec (); + double *pabs_tol = abs_tol.fortran_vec (); + + double *prwork = rwork.fortran_vec (); + octave_idx_type *piwork = iwork.fortran_vec (); + + octave_idx_type *pjroot = jroot.fortran_vec (); + + double *dummy = 0; + octave_idx_type *idummy = 0; F77_XFCN (ddasrt, DDASRT, (ddasrt_f, nn, t, px, pxdot, tout, pinfo, prel_tol, pabs_tol, istate, prwork, lrw,
--- a/liboctave/DASRT.h +++ b/liboctave/DASRT.h @@ -33,7 +33,8 @@ { public: - DASRT_result (void) { } + DASRT_result (void) + : x (), xdot (), t () { } DASRT_result (const Matrix& xx, const Matrix& xxdot, const ColumnVector& tt) : x (xx), xdot (xxdot), t (tt) { } @@ -71,14 +72,24 @@ { public: - DASRT (void) : DAERT (), DASRT_options (), initialized (false) { } + DASRT (void) + : DAERT (), DASRT_options (), initialized (false), + liw (0), lrw (0), ng (0), info (), iwork (), jroot (), rwork (), + abs_tol (), rel_tol () + { } DASRT (const ColumnVector& s, double tm, DAERTFunc& f) - : DAERT (s, tm, f), DASRT_options (), initialized (false) { } + : DAERT (s, tm, f), DASRT_options (), initialized (false), + liw (0), lrw (0), ng (0), info (), iwork (), jroot (), rwork (), + abs_tol (), rel_tol () + { } DASRT (const ColumnVector& s, const ColumnVector& deriv, double tm, DAERTFunc& f) - : DAERT (s, deriv, tm, f), DASRT_options (), initialized (false) { } + : DAERT (s, deriv, tm, f), DASRT_options (), initialized (false), + liw (0), lrw (0), ng (0), info (), iwork (), jroot (), rwork (), + abs_tol (), rel_tol () + { } ~DASRT (void) { } @@ -107,15 +118,6 @@ Array<double> abs_tol; Array<double> rel_tol; - double *px; - double *pxdot; - double *pabs_tol; - double *prel_tol; - octave_idx_type *pinfo; - octave_idx_type *piwork; - double *prwork; - octave_idx_type *pjroot; - void integrate (double t); };
--- a/liboctave/DASSL.cc +++ b/liboctave/DASSL.cc @@ -143,8 +143,6 @@ for (octave_idx_type i = 0; i < 15; i++) info(i) = 0; - pinfo = info.fortran_vec (); - octave_idx_type n = size (); liw = 21 + n; @@ -165,12 +163,6 @@ else info(3) = 0; - px = x.fortran_vec (); - pxdot = xdot.fortran_vec (); - - piwork = iwork.fortran_vec (); - prwork = rwork.fortran_vec (); - restart = false; // DAEFunc @@ -245,7 +237,7 @@ else { (*current_liboctave_error_handler) - ("dassl: invalid value for maximum order"); + ("dassl: invalid value for maximum order: %d", maxord); integration_error = true; return retval; } @@ -280,14 +272,22 @@ return retval; } - pabs_tol = abs_tol.fortran_vec (); - prel_tol = rel_tol.fortran_vec (); - DASSL_options::reset = false; } - static double *dummy = 0; - static octave_idx_type *idummy = 0; + double *px = x.fortran_vec (); + double *pxdot = xdot.fortran_vec (); + + octave_idx_type *pinfo = info.fortran_vec (); + + double *prel_tol = rel_tol.fortran_vec (); + double *pabs_tol = abs_tol.fortran_vec (); + + double *prwork = rwork.fortran_vec (); + octave_idx_type *piwork = iwork.fortran_vec (); + + double *dummy = 0; + octave_idx_type *idummy = 0; F77_XFCN (ddassl, DDASSL, (ddassl_f, nn, t, px, pxdot, tout, pinfo, prel_tol, pabs_tol, istate, prwork, lrw,
--- a/liboctave/DASSL.h +++ b/liboctave/DASSL.h @@ -35,14 +35,19 @@ { public: - DASSL (void) : DAE (), DASSL_options (), initialized (false) { } + DASSL (void) + : DAE (), DASSL_options (), initialized (false), liw (0), lrw (0), + info (), iwork (), rwork (), abs_tol (), rel_tol () { } DASSL (const ColumnVector& s, double tm, DAEFunc& f) - : DAE (s, tm, f), DASSL_options (), initialized (false) { } + : DAE (s, tm, f), DASSL_options (), initialized (false), liw (0), + lrw (0), info (), iwork (), rwork (), abs_tol (), rel_tol () { } DASSL (const ColumnVector& s, const ColumnVector& deriv, double tm, DAEFunc& f) - : DAE (s, deriv, tm, f), DASSL_options (), initialized (false) { } + : DAE (s, deriv, tm, f), DASSL_options (), initialized (false), + liw (0), lrw (0), info (), iwork (), rwork (), abs_tol (), + rel_tol () { } ~DASSL (void) { } @@ -73,14 +78,6 @@ Array<double> abs_tol; Array<double> rel_tol; - - double *px; - double *pxdot; - double *pabs_tol; - double *prel_tol; - octave_idx_type *pinfo; - octave_idx_type *piwork; - double *prwork; }; #endif
--- a/liboctave/LSODE.cc +++ b/liboctave/LSODE.cc @@ -193,11 +193,6 @@ itask = 1; } - px = x.fortran_vec (); - - piwork = iwork.fortran_vec (); - prwork = rwork.fortran_vec (); - restart = false; // ODEFunc @@ -272,11 +267,16 @@ iopt = 1; } - pabs_tol = abs_tol.fortran_vec (); - LSODE_options::reset = false; } + double *px = x.fortran_vec (); + + double *pabs_tol = abs_tol.fortran_vec (); + + octave_idx_type *piwork = iwork.fortran_vec (); + double *prwork = rwork.fortran_vec (); + F77_XFCN (dlsode, DLSODE, (lsode_f, nn, px, t, tout, itol, rel_tol, pabs_tol, itask, istate, iopt, prwork, lrw, piwork, liw, lsode_j, method_flag));
--- a/liboctave/LSODE.h +++ b/liboctave/LSODE.h @@ -35,10 +35,15 @@ { public: - LSODE (void) : ODE (), LSODE_options (), initialized (false) { } + LSODE (void) + : ODE (), LSODE_options (), initialized (false), method_flag (0), + maxord (0), itask (0), iopt (0), itol (0), liw (0), lrw (0), + iwork (), rwork (), rel_tol (0.0), abs_tol () { } LSODE (const ColumnVector& s, double tm, const ODEFunc& f) - : ODE (s, tm, f), LSODE_options (), initialized (false) { } + : ODE (s, tm, f), LSODE_options (), initialized (false), method_flag (0), + maxord (0), itask (0), iopt (0), itol (0), liw (0), lrw (0), + iwork (), rwork (), rel_tol (0.0), abs_tol () { } ~LSODE (void) { } @@ -69,11 +74,6 @@ double rel_tol; Array<double> abs_tol; - - double *px; - double *pabs_tol; - octave_idx_type *piwork; - double *prwork; }; #endif
--- a/liboctave/ODES.h +++ b/liboctave/ODES.h @@ -32,7 +32,7 @@ public: ODES (void) - : base_diff_eqn (), ODESFunc (), theta () { } + : base_diff_eqn (), ODESFunc (), xdot (), theta () { } ODES (const ColumnVector& s, double tm, ODESFunc& f) : base_diff_eqn (s, tm), ODESFunc (f), xdot (s.length (), 0.0), theta () { } @@ -43,7 +43,7 @@ theta (xtheta) { } ODES (const ODES& a) - : base_diff_eqn (a), ODESFunc (a), theta (a.theta) { } + : base_diff_eqn (a), ODESFunc (a), xdot (a.xdot), theta (a.theta) { } ODES& operator = (const ODES& a) {