26 #if defined (HAVE_CONFIG_H)
40 const double&,
double *,
F77_INT&,
double *,
44 double *,
const double&,
double *,
F77_INT *);
47 const double *,
const double *,
48 const double *,
const double&,
49 const double *,
double *,
F77_INT *,
50 double *,
const double&,
F77_INT&,
78 tmp_deriv.
elem (i) = deriv[i];
84 tmp_delta =
user_fcn (tmp_state, tmp_deriv,
time, tmp_ires);
86 ires = octave::to_f77_int (tmp_ires);
95 delta[i] = tmp_delta.
elem (i);
107 const double *,
const double *,
const double&,
108 const double *,
double *,
F77_INT *,
double *,
111 (*current_liboctave_error_handler) (
"daspk: PSOL is not implemented");
118 double *pd,
const double& cj,
double *,
F77_INT *)
127 tmp_deriv.
elem (i) = deriv[i];
135 pd[
nn * j + i] = tmp_pd.
elem (i, j);
148 || DASPK_options::m_reset)
156 for (
F77_INT i = 0; i < 20; i++)
187 (*current_liboctave_error_handler)
188 (
"daspk: inconsistent sizes for state and residual vectors");
197 (*current_liboctave_error_handler)
198 (
"daspk: no user supplied RHS subroutine!");
210 octave_idx_type eavfet = exclude_algebraic_variables_from_error_test ();
213 if (eiq == 1 || eiq == 3)
215 if (ccic == 1 || eavfet == 1)
233 if (abs_tol_len == 1 && rel_tol_len == 1)
237 else if (abs_tol_len ==
n && rel_tol_len ==
n)
244 (*current_liboctave_error_handler)
245 (
"daspk: inconsistent sizes for tolerance arrays");
251 double hmax = maximum_step_size ();
260 double h0 = initial_step_size ();
272 if (maxord > 0 && maxord < 6)
275 m_iwork(2) = octave::to_f77_int (maxord);
280 (*current_liboctave_error_handler)
281 (
"daspk: invalid value for maximum order");
300 F77_INT val = octave::to_f77_int (ict(i));
301 if (val < -2 || val > 2)
304 (*current_liboctave_error_handler)
305 (
"daspk: invalid value for inequality constraint type");
315 (*current_liboctave_error_handler)
316 (
"daspk: inequality constraint types size mismatch");
325 m_info(9) = octave::to_f77_int (eiq);
330 (*current_liboctave_error_handler)
331 (
"daspk: invalid value for enforce inequality constraints option");
349 if (eiq == 0 || eiq == 2)
351 else if (eiq == 1 || eiq == 3)
355 (
"daspk: invalid value for eiq: "
356 "%" OCTAVE_IDX_TYPE_FORMAT, eiq);
359 m_iwork(lid+i) = (av(i) ? -1 : 1);
364 (*current_liboctave_error_handler)
365 (
"daspk: algebraic variables size mismatch");
373 (*current_liboctave_error_handler)
374 (
"daspk: invalid value for compute consistent initial condition option");
379 m_info(10) = octave::to_f77_int (ccic);
395 if (eiq == 0 || eiq == 2)
397 else if (eiq == 1 || eiq == 3)
401 (
"daspk: invalid value for eiq: %" OCTAVE_IDX_TYPE_FORMAT,
405 m_iwork(lid+i) = (av(i) ? -1 : 1);
409 if (use_initial_condition_heuristics ())
413 if (ich.
numel () == 6)
426 (*current_liboctave_error_handler)
427 (
"daspk: invalid initial condition heuristics option");
441 m_info(17) = octave::to_f77_int (pici);
446 (*current_liboctave_error_handler)
447 (
"daspk: invalid value for print initial condition info option");
453 DASPK_options::m_reset =
false;
469 double *dummy =
nullptr;
475 prel_tol, pabs_tol, tmp_istate, prwork,
m_lrw,
530 (*current_liboctave_error_handler)
531 (
"unrecognized value of m_istate (= %" OCTAVE_IDX_TYPE_FORMAT
") "
554 if (n_out > 0 &&
n > 0)
574 retval.
elem (j, i) = x_next.
elem (i);
599 if (n_out > 0 &&
n > 0)
616 double next_crit = tcrit.
elem (0);
618 while (i_out < n_out)
620 bool do_restart =
false;
622 next_out = tout.
elem (i_out);
624 next_crit = tcrit.
elem (i_crit);
629 if (next_crit == next_out)
638 else if (next_crit < next_out)
673 retval.
elem (i_out-1, i) = x_next.
elem (i);
699 std::ostringstream buf;
701 std::string t_curr = buf.str ();
706 retval =
"a step was successfully taken in intermediate-output mode.";
710 retval =
"integration completed by stepping exactly to TOUT";
714 retval =
"integration to tout completed by stepping past TOUT";
718 retval =
"initial condition calculation completed successfully";
722 retval =
"a large amount of work has been expended (t =" + t_curr +
')';
726 retval =
"the error tolerances are too stringent";
730 retval =
"error weight became zero during problem. (t = " + t_curr +
731 "; solution component i vanished, and atol or atol(i) == 0)";
735 retval =
"repeated error test failures on the last attempted step (t = "
740 retval =
"the corrector could not converge (t = " + t_curr +
')';
744 retval =
"the matrix of partial derivatives is singular (t = " + t_curr +
749 retval =
"the corrector could not converge (t = " + t_curr +
750 "; repeated test failures)";
754 retval =
"corrector could not converge because IRES was -1 (t = "
759 retval =
"return requested in user-supplied function (t = " + t_curr +
764 retval =
"failed to compute consistent initial conditions";
768 retval =
"unrecoverable error encountered inside user's PSOL function (t = "
773 retval =
"the Krylov linear system solver failed to converge (t = "
778 retval =
"unrecoverable error (see printed message)";
782 retval =
"unknown error state";
static DAEFunc::DAEJacFunc user_jac
static F77_INT ddaspk_f(const double &time, const double *state, const double *deriv, const double &, double *delta, F77_INT &ires, double *, F77_INT *)
static F77_INT ddaspk_j(const double &time, const double *state, const double *deriv, double *pd, const double &cj, double *, F77_INT *)
F77_INT(* daspk_fcn_ptr)(const double &, const double *, const double *, const double &, double *, F77_INT &, double *, F77_INT *)
F77_RET_T F77_FUNC(ddaspk, DDASPK)(daspk_fcn_ptr
static DAEFunc::DAERHSFunc user_fcn
static F77_INT ddaspk_psol(const F77_INT &, const double &, const double *, const double *, const double *, const double &, const double *, double *, F77_INT *, double *, const double &, F77_INT &, double *, F77_INT *)
F77_INT(* daspk_psol_ptr)(const F77_INT &, const double &, const double *, const double *, const double *, const double &, const double *, double *, F77_INT *, double *, const double &, F77_INT &, double *, F77_INT *)
F77_INT(* daspk_jac_ptr)(const double &, const double *, const double *, double *, const double &, double *, F77_INT *)
OCTARRAY_OVERRIDABLE_FUNC_API bool isempty(void) const
Size of the specified dimension.
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type numel(void) const
Number of elements in the array.
OCTARRAY_API void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
OCTARRAY_API T * fortran_vec(void)
Size of the specified dimension.
OCTARRAY_OVERRIDABLE_FUNC_API T & elem(octave_idx_type n)
Size of the specified dimension.
DAEJacFunc jacobian_function(void) const
Matrix(* DAEJacFunc)(const ColumnVector &x, const ColumnVector &xdot, double t, double cj)
ColumnVector(* DAERHSFunc)(const ColumnVector &x, const ColumnVector &xdot, double t, octave_idx_type &ires)
DAERHSFunc function(void) const
octave_f77_int_type m_lrw
Array< double > m_rel_tol
Array< octave_f77_int_type > m_info
std::string error_message(void) const
Array< octave_f77_int_type > m_iwork
octave_f77_int_type m_liw
Array< double > m_abs_tol
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(void)
octave_idx_type size(void) const
void set_stop_time(double tt)
void clear_stop_time(void)
Vector representing the dimensions (size) of an Array.
subroutine ddaspk(RES, NEQ, T, Y, YPRIME, TOUT, INFO, RTOL, ATOL, IDID, RWORK, LRW, IWORK, LIW, RPAR, IPAR, JAC, PSOL)
#define F77_XFCN(f, F, args)
octave_f77_int_type F77_INT
OCTAVE_NORETURN liboctave_error_handler current_liboctave_error_handler
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)
octave_idx_type nint_big(double x)
static uint32_t state[624]