23 #if defined (HAVE_CONFIG_H)
82 catch (octave::execution_exception&
e)
87 if (tmp.
empty () || !
tmp(0).is_defined ())
90 if (! warned_fcn_imaginary &&
tmp(0).is_complex_type ())
92 warning (
"dasrt: ignoring imaginary part returned from user-supplied function");
93 warned_fcn_imaginary =
true;
96 retval =
tmp(0).vector_value ();
123 catch (octave::execution_exception&
e)
128 if (tmp.
empty () || !
tmp(0).is_defined ())
131 if (! warned_cf_imaginary &&
tmp(0).is_complex_type ())
133 warning (
"dasrt: ignoring imaginary part returned from user-supplied constraint function");
134 warned_cf_imaginary =
true;
137 retval =
tmp(0).vector_value ();
169 catch (octave::execution_exception&
e)
175 if (tlen == 0 || !
tmp(0).is_defined ())
178 if (! warned_jac_imaginary &&
tmp(0).is_complex_type ())
180 warning (
"dasrt: ignoring imaginary part returned from user-supplied jacobian function");
181 warned_jac_imaginary =
true;
184 retval =
tmp(0).matrix_value ();
336 if (nargin < 4 || nargin > 6)
339 warned_fcn_imaginary =
false;
340 warned_jac_imaginary =
false;
341 warned_cf_imaginary =
false;
351 error (
"dasrt: invalid recursive call");
370 else if (c.
numel () == 2)
372 if (
c(0).is_function_handle () ||
c(0).is_inline_function ())
373 dasrt_f =
c(0).function_value ();
377 fname =
"function y = ";
378 fname.append (fcn_name);
379 fname.append (
" (x, xdot, t) y = ");
386 if (
c(1).is_function_handle () ||
c(1).is_inline_function ())
387 dasrt_j =
c(1).function_value ();
391 jname =
"function jac = ";
392 jname.append (jac_name);
393 jname.append (
" (x, xdot, t, cj) jac = ");
399 if (fcn_name.length ())
407 error (
"dasrt: incorrect number of elements in cell array");
410 if (! dasrt_f && ! f_arg.
is_cell ())
416 switch (f_arg.
rows ())
420 fname =
"function y = ";
421 fname.append (fcn_name);
422 fname.append (
" (x, xdot, t) y = ");
432 fname =
"function y = ";
433 fname.append (fcn_name);
434 fname.append (
" (x, xdot, t) y = ");
436 fname,
"; endfunction");
441 jname =
"function jac = ";
442 jname.append (jac_name);
443 jname.append (
" (x, xdot, t, cj) jac = ");
445 jname,
"; endfunction");
454 error (
"dasrt: first arg should be a string or 2-element string array");
466 if (
args(1).is_function_handle () ||
args(1).is_inline_function ())
468 dasrt_cf =
args(1).function_value ();
471 error (
"dasrt: invalid constraint function G");
477 else if (
args(1).is_string ())
481 error (
"dasrt: invalid constraint function G");
490 ColumnVector stateprime =
args(argp).xvector_value (
"dasrt: initial derivatives XDOT_0 must be a vector");
493 ColumnVector out_times =
args(argp).xvector_value (
"dasrt: output time variable T must be a vector");
496 double tzero = out_times (0);
500 bool crit_times_set =
false;
504 crit_times =
args(argp).xvector_value (
"dasrt: list of critical times T_CRIT must be a vector");
507 crit_times_set =
true;
515 DASRT dae =
DASRT (state, stateprime, tzero, func);
520 output = dae.
integrate (out_times, crit_times);
524 if (fcn_name.length ())
526 if (jac_name.length ())
540 error (
"dasrt: %s", msg.c_str ());
bool is_empty(void) const
virtual octave_value_list do_multi_index_op(int nargout, const octave_value_list &idx)
octave_idx_type rows(void) const
bool integration_ok(void) const
OCTINTERP_API void print_usage(void)
octave_idx_type numel(void) const
Number of elements in the array.
octave_idx_type length(void) const
DAERTFunc & set_constraint_function(DAERTConstrFunc cf)
void error(const char *fmt,...)
static DASRT_options dasrt_opts
static octave_function * dasrt_j
std::string error_message(void) const
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function t
bool is_function_handle(void) const
std::string unique_symbol_name(const std::string &basename)
Cell cell_value(void) const
void clear_function(const std::string &nm)
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function xample nargout(@histc)
static octave_function * dasrt_cf
DEFUN(dasrt, args, nargout, doc:)
bool is_inline_function(void) const
ColumnVector times(void) const
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
DASRT_result integrate(const ColumnVector &tout)
static bool warned_cf_imaginary
static uint32_t state[624]
octave_function * function_value(bool silent=false) const
void warning(const char *fmt,...)
octave::unwind_protect frame
static ColumnVector dasrt_user_f(const ColumnVector &x, const ColumnVector &xdot, double t, octave_idx_type &)
static ColumnVector dasrt_user_cf(const ColumnVector &x, double t)
void err_user_supplied_eval(const char *name)
static Matrix dasrt_user_j(const ColumnVector &x, const ColumnVector &xdot, double t, double cj)
static bool warned_fcn_imaginary
octave_function * extract_function(const octave_value &arg, const std::string &warn_for, const std::string &fname, const std::string &header, const std::string &trailer)
octave_idx_type integration_state(void) const
octave_function * is_valid_function(const std::string &fcn_name, const std::string &warn_for, bool warn)
void set_options(const DASRT_options &opt)
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
static octave_function * dasrt_f
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE * x
static bool warned_jac_imaginary
DAEFunc & set_jacobian_function(DAEJacFunc j)