26 #if defined (HAVE_CONFIG_H)
40 const double *,
double *,
F77_INT&,
44 const double *,
double *,
const double&,
64 ddassl_f (
const double&
time,
const double *state,
const double *deriv,
73 for (
F77_INT i = 0; i < nn; i++)
75 tmp_deriv.
elem (i) = deriv[i];
76 tmp_state.
elem (i) = state[i];
81 tmp_delta = user_fcn (tmp_state, tmp_deriv,
time, tmp_ires);
83 ires = octave::to_f77_int (tmp_ires);
91 for (
F77_INT i = 0; i < nn; i++)
92 delta[i] = tmp_delta.
elem (i);
100 ddassl_j (
const double&
time,
const double *state,
const double *deriv,
101 double *pd,
const double& cj,
double *,
F77_INT *)
108 for (
F77_INT i = 0; i < nn; i++)
110 tmp_deriv.
elem (i) = deriv[i];
111 tmp_state.
elem (i) = state[i];
114 Matrix tmp_pd = user_jac (tmp_state, tmp_deriv,
time, cj);
116 for (
F77_INT j = 0; j < nn; j++)
117 for (
F77_INT i = 0; i < nn; i++)
118 pd[nn * j + i] = tmp_pd.
elem (i, j);
133 m_initialized =
true;
137 for (
F77_INT i = 0; i < 15; i++)
143 m_lrw = 40 + 9*
n +
n*
n;
175 (*current_liboctave_error_handler)
176 (
"dassl: inconsistent sizes for state and residual vectors");
184 (*current_liboctave_error_handler)
185 (
"dassl: no user supplied RHS subroutine!");
191 m_info(4) = (user_jac ? 1 : 0);
228 if (maxord > 0 && maxord < 6)
235 (*current_liboctave_error_handler)
236 (
"dassl: invalid value for maximum order: %"
237 OCTAVE_F77_INT_TYPE_FORMAT, maxord);
244 m_info(9) = (enc ? 1 : 0);
247 m_info(10) = (ccic ? 1 : 0);
252 F77_INT abs_tol_len = octave::to_f77_int (m_abs_tol.
numel ());
253 F77_INT rel_tol_len = octave::to_f77_int (m_rel_tol.
numel ());
255 if (abs_tol_len == 1 && rel_tol_len == 1)
259 else if (abs_tol_len ==
n && rel_tol_len ==
n)
265 (*current_liboctave_error_handler)
266 (
"dassl: inconsistent sizes for tolerance arrays");
286 double *dummy =
nullptr;
292 prel_tol, pabs_tol, tmp_istate, prwork, m_lrw,
293 piwork, m_liw, dummy, idummy, ddassl_j));
337 (*current_liboctave_error_handler)
338 (
"unrecognized value of istate (= %" OCTAVE_IDX_TYPE_FORMAT
") "
361 if (n_out > 0 &&
n > 0)
381 retval.
elem (j, i) = x_next.
elem (i);
406 if (n_out > 0 &&
n > 0)
423 double next_crit = tcrit.
elem (0);
425 while (i_out < n_out)
427 bool do_restart =
false;
429 next_out = tout.
elem (i_out);
431 next_crit = tcrit.
elem (i_crit);
436 if (next_crit == next_out)
445 else if (next_crit < next_out)
480 retval.
elem (i_out-1, i) = x_next.
elem (i);
506 std::ostringstream buf;
508 std::string t_curr = buf.str ();
513 retval =
"a step was successfully taken in intermediate-output mode.";
517 retval =
"integration completed by stepping exactly to TOUT";
521 retval =
"integration to tout completed by stepping past TOUT";
525 retval =
"a large amount of work has been expended (t =" + t_curr +
')';
529 retval =
"the error tolerances are too stringent";
533 retval =
"error weight became zero during problem. (t = " + t_curr +
534 "; solution component i vanished, and atol or atol(i) == 0)";
538 retval =
"repeated error test failures on the last attempted step (t = "
543 retval =
"the corrector could not converge (t = " + t_curr +
')';
547 retval =
"the matrix of partial derivatives is singular (t = " + t_curr +
552 retval =
"the corrector could not converge (t = " + t_curr +
553 "; repeated test failures)";
557 retval =
"corrector could not converge because IRES was -1 (t = "
562 retval =
"return requested in user-supplied function (t = " + t_curr +
567 retval =
"failed to compute consistent initial conditions";
571 retval =
"unrecoverable error (see printed message)";
575 retval =
"unknown error state";
F77_INT(* dassl_fcn_ptr)(const double &, const double *, const double *, double *, F77_INT &, double *, F77_INT *)
F77_INT(* dassl_jac_ptr)(const double &, const double *, const double *, double *, const double &, double *, F77_INT *)
F77_RET_T F77_FUNC(ddassl, DDASSL)(dassl_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.
DAEJacFunc jacobian_function() const
Matrix(* DAEJacFunc)(const ColumnVector &x, const ColumnVector &xdot, double t, double cj)
DAERHSFunc function() const
ColumnVector(* DAERHSFunc)(const ColumnVector &x, const ColumnVector &xdot, double t, octave_idx_type &ires)
Array< double > relative_tolerance() const
octave_idx_type compute_consistent_initial_condition() const
octave_idx_type maximum_order() const
Array< double > absolute_tolerance() const
double initial_step_size() const
double maximum_step_size() const
octave_idx_type enforce_nonnegativity_constraints() const
octave_idx_type step_limit() const
std::string error_message() const
Matrix integrate(const ColumnVector &tout, Matrix &xdot_out)
ColumnVector do_integrate(double t)
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
virtual void force_restart()
octave_idx_type size() const
void set_stop_time(double tt)
Vector representing the dimensions (size) of an Array.
subroutine ddassl(RES, NEQ, T, Y, YPRIME, TOUT, INFO, RTOL, ATOL, IDID, RWORK, LRW, IWORK, LIW, RPAR, IPAR, JAC)
#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)