26 #if defined (HAVE_CONFIG_H)
58 static bool user_jac_ignore_ml_mu;
61 lsode_f (
const F77_INT& neq,
const double&
time,
double *,
double *deriv,
70 tmp_deriv = (*user_fcn) (*tmp_x,
time);
76 for (
F77_INT i = 0; i < neq; i++)
77 deriv[i] = tmp_deriv.
elem (i);
84 lsode_j (
const F77_INT& neq,
const double&
time,
double *,
86 double *pd,
const F77_INT& nrowpd)
94 tmp_jac = (*user_jac) (*tmp_x,
time);
96 if (user_jac_ignore_ml_mu)
97 for (
F77_INT j = 0; j < neq; j++)
98 for (
F77_INT i = 0; i < neq; i++)
99 pd[nrowpd * j + i] = tmp_jac (i, j);
102 for (
F77_INT i = 0, j = mu; i <= ml; j == 0 ? i++ : j--)
104 for (
F77_INT k = i, l = j; k < neq && l < neq; k++, l++)
105 pd[nrowpd * l + k + mu - l] = tmp_jac (k, l);
122 m_initialized =
true;
132 user_jac_ignore_ml_mu =
true;
149 user_jac_ignore_ml_mu =
false;
165 (*current_liboctave_error_handler)
166 (
"lsode: internal error, wrong jacobian type");
173 m_lrw = 22 +
n * (9 +
n);
187 for (
F77_INT i = 4; i < 9; i++)
192 for (
F77_INT i = 4; i < 9; i++)
199 if (maxord > 0 && maxord <= max_maxord)
201 m_iwork(4) = octave::to_f77_int (maxord);
207 (*current_liboctave_error_handler)
208 (
"lsode: invalid value for maximum order");
235 user_fcn =
function ();
243 (*current_liboctave_error_handler)
244 (
"lsode: inconsistent sizes for state and derivative vectors");
257 F77_INT abs_tol_len = octave::to_f77_int (m_abs_tol.
numel ());
259 if (abs_tol_len == 1)
261 else if (abs_tol_len ==
n)
266 (*current_liboctave_error_handler)
267 (
"lsode: inconsistent sizes for state and absolute tolerance vectors");
314 pabs_tol, m_itask, tmp_istate, m_iopt, prwork,
315 m_lrw, piwork, m_liw, lsode_j, m_method_flag));
341 (*current_liboctave_error_handler)
342 (
"unrecognized value of istate (= %" OCTAVE_IDX_TYPE_FORMAT
") "
355 std::ostringstream buf;
357 std::string t_curr = buf.str ();
362 retval =
"prior to initial integration step";
366 retval =
"successful exit";
370 retval =
"prior to continuation call with modified parameters";
374 retval =
"excess work on this call (t = " + t_curr +
375 "; perhaps wrong integration method)";
379 retval =
"excess accuracy requested (tolerances too small)";
383 retval =
"invalid input detected (see printed message)";
387 retval =
"repeated error test failures (t = " + t_curr +
388 "; check all inputs)";
392 retval =
"repeated convergence failures (t = " + t_curr +
393 "; perhaps bad Jacobian supplied or wrong choice of integration method or tolerances)";
397 retval =
"error weight became zero during problem. (t = " + t_curr +
398 "; solution component i vanished, and atol or atol(i) == 0)";
402 retval =
"return requested in user-supplied function (t = "
407 retval =
"unknown error state";
422 if (n_out > 0 &&
n > 0)
437 retval.
elem (j, i) = x_next.
elem (i);
452 if (n_out > 0 &&
n > 0)
465 double next_crit = tcrit.
elem (0);
467 while (i_out < n_out)
469 bool do_restart =
false;
471 next_out = tout.
elem (i_out);
473 next_crit = tcrit.
elem (i_crit);
475 bool save_output =
false;
478 if (next_crit == next_out)
487 else if (next_crit < next_out)
521 retval.
elem (i_out-1, i) = x_next.
elem (i);
F77_INT(* lsode_jac_ptr)(const F77_INT &, const double &, double *, const F77_INT &, const F77_INT &, double *, const F77_INT &)
F77_INT(* lsode_fcn_ptr)(const F77_INT &, const double &, double *, double *, F77_INT &)
F77_RET_T F77_FUNC(dlsode, DLSODE)(lsode_fcn_ptr
T & elem(octave_idx_type n)
Size of the specified dimension.
T * fortran_vec()
Size of the specified dimension.
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
bool isempty() const
Size of the specified dimension.
octave_idx_type numel() const
Number of elements in the array.
std::string jacobian_type() const
double minimum_step_size() const
octave_idx_type lower_jacobian_subdiagonals() const
std::string integration_method() const
octave_idx_type step_limit() const
octave_idx_type maximum_order() const
octave_idx_type upper_jacobian_subdiagonals() const
double relative_tolerance() const
double maximum_step_size() const
double initial_step_size() const
Array< double > absolute_tolerance() const
std::string error_message() const
ColumnVector do_integrate(double t)
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
ColumnVector(* ODERHSFunc)(const ColumnVector &, double)
Matrix(* ODEJacFunc)(const ColumnVector &, double)
ODEJacFunc jacobian_function() const
virtual void force_restart()
octave_idx_type size() const
void set_stop_time(double tt)
Vector representing the dimensions (size) of an Array.
subroutine dlsode(F, NEQ, Y, T, TOUT, ITOL, RTOL, ATOL, ITASK, ISTATE, IOPT, RWORK, LRW, IWORK, LIW, JAC, MF)
#define F77_XFCN(f, F, args)
octave_f77_int_type F77_INT
F77_RET_T(F77_CONST_CHAR_ARG_DECL, F77_CONST_CHAR_ARG_DECL, F77_CONST_CHAR_ARG_DECL, const F77_INT &, const F77_INT &, const F77_INT &, F77_INT &, F77_INT &, F77_DBLE *, const F77_INT &, F77_DBLE *, const F77_INT &, F77_DBLE *, F77_DBLE *, F77_DBLE *, const F77_INT &, F77_DBLE *, const F77_INT &, F77_DBLE *, const F77_INT &, F77_DBLE *, F77_INT *, F77_INT &F77_CHAR_ARG_LEN_DECL F77_CHAR_ARG_LEN_DECL F77_CHAR_ARG_LEN_DECL)
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE const F77_INT F77_INT & ierr