26 #if defined (HAVE_CONFIG_H)
42 double *,
const double&,
double *,
F77_INT *);
67 ddasrt_f (
const double& t,
const double *state,
const double *deriv,
73 for (
F77_INT i = 0; i < nn; i++)
75 tmp_state(i) = state[i];
76 tmp_deriv(i) = deriv[i];
81 ColumnVector tmp_fval = (*user_fsub) (tmp_state, tmp_deriv, t, tmp_ires);
83 ires = octave::to_f77_int (tmp_ires);
89 for (
F77_INT i = 0; i < nn; i++)
90 delta[i] = tmp_fval(i);
97 ddasrt_j (
const double&
time,
const double *state,
const double *deriv,
98 double *pd,
const double& cj,
double *,
F77_INT *)
105 for (
F77_INT i = 0; i < nn; i++)
107 tmp_deriv.
elem (i) = deriv[i];
108 tmp_state.
elem (i) = state[i];
111 Matrix tmp_pd = (*user_jsub) (tmp_state, tmp_deriv,
time, cj);
113 for (
F77_INT j = 0; j < nn; j++)
114 for (
F77_INT i = 0; i < nn; i++)
115 pd[nn * j + i] = tmp_pd.
elem (i, j);
121 ddasrt_g (
const F77_INT& neq,
const double& t,
const double *state,
128 tmp_state(i) = state[i];
132 for (
F77_INT i = 0; i < m_ng; i++)
133 gout[i] = tmp_fval(i);
150 m_initialized =
true;
154 for (
F77_INT i = 0; i < 15; i++)
168 m_ng = octave::to_f77_int (tmp.
numel ());
176 if (maxord > 0 && maxord < 6)
183 (*current_liboctave_error_handler)
184 (
"dassl: invalid value for maximum order");
191 m_lrw = 50 + 9*
n +
n*
n + 3*m_ng;
221 (*current_liboctave_error_handler)
222 (
"dasrt: inconsistent sizes for state and residual vectors");
230 (*current_liboctave_error_handler)
231 (
"dasrt: no user supplied RHS subroutine!");
237 m_info(4) = (user_jsub ? 1 : 0);
277 F77_INT abs_tol_len = octave::to_f77_int (m_abs_tol.
numel ());
278 F77_INT rel_tol_len = octave::to_f77_int (m_rel_tol.
numel ());
280 if (abs_tol_len == 1 && rel_tol_len == 1)
284 else if (abs_tol_len ==
n && rel_tol_len ==
n)
290 (*current_liboctave_error_handler)
291 (
"dasrt: inconsistent sizes for tolerance arrays");
313 double *dummy =
nullptr;
319 prel_tol, pabs_tol, tmp_istate, prwork, m_lrw,
320 piwork, m_liw, dummy, idummy,
ddasrt_j,
321 ddasrt_g, m_ng, pjroot));
368 (*current_liboctave_error_handler)
369 (
"unrecognized value of istate (= %" OCTAVE_IDX_TYPE_FORMAT
") "
387 if (n_out > 0 &&
n > 0)
394 x_out(0, i) =
m_x(i);
395 xdot_out(0, i) =
m_xdot(i);
415 x_out(j, i) =
m_x(i);
416 xdot_out(j, i) =
m_xdot(i);
446 if (n_out > 0 &&
n > 0)
457 double next_crit = tcrit(0);
459 while (i_out < n_out)
461 bool do_restart =
false;
463 next_out = tout(i_out);
465 next_crit = tcrit(i_crit);
467 bool save_output =
false;
470 if (next_crit == next_out)
479 else if (next_crit < next_out)
520 x_out(i_out-1, i) =
m_x(i);
521 xdot_out(i_out-1, i) =
m_xdot(i);
524 t_outs(i_out-1) = t_out;
558 std::ostringstream buf;
560 std::string t_curr = buf.str ();
565 retval =
"a step was successfully taken in intermediate-output mode.";
569 retval =
"integration completed by stepping exactly to TOUT";
573 retval =
"integration to tout completed by stepping past TOUT";
577 retval =
"integration completed by finding one or more roots of G at T";
581 retval =
"a large amount of work has been expended (t =" + t_curr +
')';
585 retval =
"the error tolerances are too stringent";
589 retval =
"error weight became zero during problem. (t = " + t_curr +
590 "; solution component i vanished, and atol or atol(i) == 0)";
594 retval =
"repeated error test failures on the last attempted step (t = "
599 retval =
"the corrector could not converge (t = " + t_curr +
')';
603 retval =
"the matrix of partial derivatives is singular (t = " + t_curr +
608 retval =
"the corrector could not converge (t = " + t_curr +
609 "; repeated test failures)";
613 retval =
"corrector could not converge because IRES was -1 (t = "
618 retval =
"return requested in user-supplied function (t = " + t_curr +
623 retval =
"failed to compute consistent initial conditions";
627 retval =
"unrecoverable error (see printed message)";
631 retval =
"unknown error state";
F77_INT(* dasrt_jac_ptr)(const double &, const double *, const double *, double *, const double &, double *, F77_INT *)
F77_RET_T F77_FUNC(ddasrt, DDASRT)(dasrt_fcn_ptr
F77_INT(* dasrt_fcn_ptr)(const double &, const double *, const double *, double *, F77_INT &, double *, F77_INT *)
F77_INT(* dasrt_constr_ptr)(const F77_INT &, const double &, const double *, const F77_INT &, double *, double *, F77_INT *)
F77_INT ddasrt_j(const double &time, const double *state, const double *deriv, double *pd, const double &cj, double *, F77_INT *)
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.
void resize(octave_idx_type n, const double &rfv=0)
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)
ColumnVector(* DAERTConstrFunc)(const ColumnVector &x, double t)
DAERTConstrFunc constraint_function() const
octave_idx_type maximum_order() const
octave_idx_type step_limit() const
Array< double > relative_tolerance() const
double initial_step_size() const
Array< double > absolute_tolerance() const
double maximum_step_size() const
DASRT_result integrate(const ColumnVector &tout)
std::string error_message() const
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 ddasrt(RES, NEQ, T, Y, YPRIME, TOUT, INFO, RTOL, ATOL, IDID, RWORK, LRW, IWORK, LIW, RPAR, IPAR, JAC, G, NG, JROOT)
#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)