Mercurial > octave
diff liboctave/numeric/LSODE.cc @ 22960:0d1422cb7e93
use F77_INT instead of octave_idx_type for liboctave ODE and DAE classes
* DASPK.cc, DASRT.cc, DASSL.cc, LSODE.cc: Use F77_INT instead of
octave_idx_type for integer data passed to Fortran subroutines.
* DASPK.h, DASRT.h, DASSL.h, LSODE.h: Use octave_f77_int_type as
needed in public interface files.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 27 Dec 2016 11:58:30 -0500 |
parents | 3a2b891d0b33 |
children | cd33c785e80e |
line wrap: on
line diff
--- a/liboctave/numeric/LSODE.cc Tue Dec 27 10:24:03 2016 -0500 +++ b/liboctave/numeric/LSODE.cc Tue Dec 27 11:58:30 2016 -0500 @@ -34,25 +34,20 @@ #include "lo-math.h" #include "quit.h" -typedef octave_idx_type (*lsode_fcn_ptr) (const octave_idx_type&, - const double&, double*, - double*, octave_idx_type&); +typedef F77_INT (*lsode_fcn_ptr) (const F77_INT&, const double&, double*, + double*, F77_INT&); -typedef octave_idx_type (*lsode_jac_ptr) (const octave_idx_type&, - const double&, double*, - const octave_idx_type&, - const octave_idx_type&, - double*, const octave_idx_type&); +typedef F77_INT (*lsode_jac_ptr) (const F77_INT&, const double&, double*, + const F77_INT&, const F77_INT&, double*, + const F77_INT&); extern "C" { F77_RET_T - F77_FUNC (dlsode, DLSODE) (lsode_fcn_ptr, F77_INT&, F77_DBLE*, - F77_DBLE&, F77_DBLE&, F77_INT&, F77_DBLE&, - const F77_DBLE*, F77_INT&, - F77_INT&, F77_INT&, - F77_DBLE*, F77_INT&, F77_INT*, - F77_INT&, lsode_jac_ptr, + F77_FUNC (dlsode, DLSODE) (lsode_fcn_ptr, F77_INT&, F77_DBLE*, F77_DBLE&, + F77_DBLE&, F77_INT&, F77_DBLE&, const F77_DBLE*, + F77_INT&, F77_INT&, F77_INT&, F77_DBLE*, + F77_INT&, F77_INT*, F77_INT&, lsode_jac_ptr, F77_INT&); } @@ -60,9 +55,9 @@ static ODEFunc::ODEJacFunc user_jac; static ColumnVector *tmp_x; -static octave_idx_type -lsode_f (const octave_idx_type& neq, const double& time, double *, - double *deriv, octave_idx_type& ierr) +static F77_INT +lsode_f (const F77_INT& neq, const double& time, double *, double *deriv, + F77_INT& ierr) { BEGIN_INTERRUPT_WITH_EXCEPTIONS; @@ -78,7 +73,7 @@ ierr = -1; else { - for (octave_idx_type i = 0; i < neq; i++) + for (F77_INT i = 0; i < neq; i++) deriv[i] = tmp_deriv.elem (i); } @@ -87,10 +82,9 @@ return 0; } -static octave_idx_type -lsode_j (const octave_idx_type& neq, const double& time, double *, - const octave_idx_type&, const octave_idx_type&, double *pd, - const octave_idx_type& nrowpd) +static F77_INT +lsode_j (const F77_INT& neq, const double& time, double *, const F77_INT&, + const F77_INT&, double *pd, const F77_INT& nrowpd) { BEGIN_INTERRUPT_WITH_EXCEPTIONS; @@ -102,8 +96,8 @@ tmp_jac = (*user_jac) (*tmp_x, time); - for (octave_idx_type j = 0; j < neq; j++) - for (octave_idx_type i = 0; i < neq; i++) + for (F77_INT j = 0; j < neq; j++) + for (F77_INT i = 0; i < neq; i++) pd[nrowpd * j + i] = tmp_jac (i, j); END_INTERRUPT_WITH_EXCEPTIONS; @@ -116,7 +110,7 @@ { ColumnVector retval; - static octave_idx_type nn = 0; + static F77_INT nn = 0; if (! initialized || restart || ODEFunc::reset || LSODE_options::reset) { @@ -126,7 +120,7 @@ istate = 1; - octave_idx_type n = size (); + F77_INT n = to_f77_int (size ()); nn = n; @@ -154,23 +148,23 @@ lrw = 22 + 16 * n; } - maxord = maximum_order (); - iwork.resize (dim_vector (liw, 1)); - for (octave_idx_type i = 4; i < 9; i++) + for (F77_INT i = 4; i < 9; i++) iwork(i) = 0; rwork.resize (dim_vector (lrw, 1)); - for (octave_idx_type i = 4; i < 9; i++) + for (F77_INT i = 4; i < 9; i++) rwork(i) = 0; + octave_idx_type maxord = maximum_order (); + if (maxord >= 0) { if (maxord > 0 && maxord <= max_maxord) { - iwork(4) = maxord; + iwork(4) = to_f77_int (maxord); iopt = 1; } else @@ -226,7 +220,7 @@ rel_tol = relative_tolerance (); abs_tol = absolute_tolerance (); - octave_idx_type abs_tol_len = abs_tol.numel (); + F77_INT abs_tol_len = to_f77_int (abs_tol.numel ()); if (abs_tol_len == 1) itol = 1; @@ -263,7 +257,7 @@ iopt = 1; } - octave_idx_type sl = step_limit (); + F77_INT sl = to_f77_int (step_limit ()); if (sl > 0) { iwork(5) = sl; @@ -277,13 +271,17 @@ double *pabs_tol = abs_tol.fortran_vec (); - octave_idx_type *piwork = iwork.fortran_vec (); + F77_INT *piwork = iwork.fortran_vec (); double *prwork = rwork.fortran_vec (); + F77_INT tmp_istate = to_f77_int (istate); + F77_XFCN (dlsode, DLSODE, (lsode_f, nn, px, t, tout, itol, rel_tol, - pabs_tol, itask, istate, iopt, prwork, lrw, + pabs_tol, itask, tmp_istate, iopt, prwork, lrw, piwork, liw, lsode_j, method_flag)); + istate = tmp_istate; + switch (istate) { case 1: // prior to initial integration step. @@ -386,13 +384,13 @@ Matrix retval; octave_idx_type n_out = tout.numel (); - octave_idx_type n = size (); + F77_INT n = to_f77_int (size ()); if (n_out > 0 && n > 0) { retval.resize (n_out, n); - for (octave_idx_type i = 0; i < n; i++) + for (F77_INT i = 0; i < n; i++) retval.elem (0, i) = x.elem (i); for (octave_idx_type j = 1; j < n_out; j++) @@ -402,7 +400,7 @@ if (integration_error) return retval; - for (octave_idx_type i = 0; i < n; i++) + for (F77_INT i = 0; i < n; i++) retval.elem (j, i) = x_next.elem (i); } } @@ -416,13 +414,13 @@ Matrix retval; octave_idx_type n_out = tout.numel (); - octave_idx_type n = size (); + F77_INT n = to_f77_int (size ()); if (n_out > 0 && n > 0) { retval.resize (n_out, n); - for (octave_idx_type i = 0; i < n; i++) + for (F77_INT i = 0; i < n; i++) retval.elem (0, i) = x.elem (i); octave_idx_type n_crit = tcrit.numel (); @@ -441,14 +439,14 @@ if (i_crit < n_crit) next_crit = tcrit.elem (i_crit); - octave_idx_type save_output; + bool save_output = false; double t_out; if (next_crit == next_out) { set_stop_time (next_crit); t_out = next_out; - save_output = 1; + save_output = true; i_out++; i_crit++; do_restart = true; @@ -459,7 +457,7 @@ { set_stop_time (next_crit); t_out = next_crit; - save_output = 0; + save_output = false; i_crit++; do_restart = true; } @@ -467,7 +465,7 @@ { clear_stop_time (); t_out = next_out; - save_output = 1; + save_output = true; i_out++; } } @@ -475,7 +473,7 @@ { set_stop_time (next_crit); t_out = next_out; - save_output = 1; + save_output = true; i_out++; } @@ -486,7 +484,7 @@ if (save_output) { - for (octave_idx_type i = 0; i < n; i++) + for (F77_INT i = 0; i < n; i++) retval.elem (i_out-1, i) = x_next.elem (i); }