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_fun (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);
155 for (
F77_INT i = 0; i < 20; i++)
186 (*current_liboctave_error_handler)
187 (
"daspk: inconsistent sizes for state and residual vectors");
196 (*current_liboctave_error_handler)
197 (
"daspk: no user supplied RHS subroutine!");
209 octave_idx_type eavfet = exclude_algebraic_variables_from_error_test ();
212 if (eiq == 1 || eiq == 3)
214 if (ccic == 1 || eavfet == 1)
226 abs_tol = absolute_tolerance ();
227 rel_tol = relative_tolerance ();
232 if (abs_tol_len == 1 && rel_tol_len == 1)
236 else if (abs_tol_len ==
n && rel_tol_len ==
n)
243 (*current_liboctave_error_handler)
244 (
"daspk: inconsistent sizes for tolerance arrays");
250 double hmax = maximum_step_size ();
259 double h0 = initial_step_size ();
271 if (maxord > 0 && maxord < 6)
274 iwork(2) = octave::to_f77_int (maxord);
279 (*current_liboctave_error_handler)
280 (
"daspk: invalid value for maximum order");
299 F77_INT val = octave::to_f77_int (ict(i));
300 if (val < -2 || val > 2)
303 (*current_liboctave_error_handler)
304 (
"daspk: invalid value for inequality constraint type");
314 (*current_liboctave_error_handler)
315 (
"daspk: inequality constraint types size mismatch");
324 info(9) = octave::to_f77_int (eiq);
329 (*current_liboctave_error_handler)
330 (
"daspk: invalid value for enforce inequality constraints option");
348 if (eiq == 0 || eiq == 2)
350 else if (eiq == 1 || eiq == 3)
354 (
"daspk: invalid value for eiq: "
355 "%" OCTAVE_IDX_TYPE_FORMAT, eiq);
358 iwork(lid+i) = (av(i) ? -1 : 1);
363 (*current_liboctave_error_handler)
364 (
"daspk: algebraic variables size mismatch");
372 (*current_liboctave_error_handler)
373 (
"daspk: invalid value for compute consistent initial condition option");
378 info(10) = octave::to_f77_int (ccic);
394 if (eiq == 0 || eiq == 2)
396 else if (eiq == 1 || eiq == 3)
400 (
"daspk: invalid value for eiq: %" OCTAVE_IDX_TYPE_FORMAT,
404 iwork(lid+i) = (av(i) ? -1 : 1);
408 if (use_initial_condition_heuristics ())
412 if (ich.
numel () == 6)
425 (*current_liboctave_error_handler)
426 (
"daspk: invalid initial condition heuristics option");
440 info(17) = octave::to_f77_int (pici);
445 (*current_liboctave_error_handler)
446 (
"daspk: invalid value for print initial condition info option");
452 DASPK_options::reset =
false;
468 double *dummy =
nullptr;
474 prel_tol, pabs_tol, tmp_istate, prwork,
lrw,
529 (*current_liboctave_error_handler)
530 (
"unrecognized value of istate (= %" OCTAVE_IDX_TYPE_FORMAT
") "
531 "returned from ddaspk",
istate);
553 if (n_out > 0 &&
n > 0)
598 if (n_out > 0 &&
n > 0)
615 double next_crit = tcrit.
elem (0);
617 while (i_out < n_out)
619 bool do_restart =
false;
621 next_out = tout.
elem (i_out);
623 next_crit = tcrit.
elem (i_crit);
628 if (next_crit == next_out)
637 else if (next_crit < next_out)
698 std::ostringstream buf;
700 std::string t_curr = buf.str ();
705 retval =
"a step was successfully taken in intermediate-output mode.";
709 retval =
"integration completed by stepping exactly to TOUT";
713 retval =
"integration to tout completed by stepping past TOUT";
717 retval =
"initial condition calculation completed successfully";
721 retval =
"a large amount of work has been expended (t =" + t_curr +
')';
725 retval =
"the error tolerances are too stringent";
729 retval =
"error weight became zero during problem. (t = " + t_curr +
730 "; solution component i vanished, and atol or atol(i) == 0)";
734 retval =
"repeated error test failures on the last attempted step (t = "
739 retval =
"the corrector could not converge (t = " + t_curr +
')';
743 retval =
"the matrix of partial derivatives is singular (t = " + t_curr +
748 retval =
"the corrector could not converge (t = " + t_curr +
749 "; repeated test failures)";
753 retval =
"corrector could not converge because IRES was -1 (t = "
758 retval =
"return requested in user-supplied function (t = " + t_curr +
763 retval =
"failed to compute consistent initial conditions";
767 retval =
"unrecoverable error encountered inside user's PSOL function (t = "
772 retval =
"the Krylov linear system solver failed to converge (t = "
777 retval =
"unrecoverable error (see printed message)";
781 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 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 *)
static DAEFunc::DAERHSFunc user_fun
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 *)
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
octave_idx_type numel(void) const
Number of elements in the array.
T & elem(octave_idx_type n)
Size of the specified dimension.
const T * fortran_vec(void) const
Size of the specified dimension.
bool isempty(void) const
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
Array< octave_f77_int_type > iwork
std::string error_message(void) const
Array< octave_f77_int_type > info
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]
octave_value::octave_value(const Array< char > &chm, char type) return retval