23 #if defined (HAVE_CONFIG_H)
82 catch (octave::execution_exception&
e)
88 if (tlen == 0 || !
tmp(0).is_defined ())
91 if (! warned_fcn_imaginary &&
tmp(0).is_complex_type ())
93 warning (
"dassl: ignoring imaginary part returned from user-supplied function");
94 warned_fcn_imaginary =
true;
97 retval =
tmp(0).vector_value ();
100 ires =
tmp(1).int_value ();
132 catch (octave::execution_exception&
e)
138 if (tlen == 0 || !
tmp(0).is_defined ())
141 if (! warned_jac_imaginary &&
tmp(0).is_complex_type ())
143 warning (
"dassl: ignoring imaginary part returned from user-supplied jacobian function");
144 warned_jac_imaginary =
true;
147 retval =
tmp(0).matrix_value ();
260 if (nargin < 4 || nargin > 5)
263 warned_fcn_imaginary =
false;
264 warned_jac_imaginary =
false;
274 error (
"dassl: invalid recursive call");
287 else if (c.
numel () == 2)
289 if (
c(0).is_function_handle () ||
c(0).is_inline_function ())
290 dassl_fcn =
c(0).function_value ();
294 fname =
"function y = ";
295 fname.append (fcn_name);
296 fname.append (
" (x, xdot, t) y = ");
303 if (
c(1).is_function_handle () ||
c(1).is_inline_function ())
304 dassl_jac =
c(1).function_value ();
308 jname =
"function jac = ";
309 jname.append (jac_name);
310 jname.append (
" (x, xdot, t, cj) jac = ");
312 jname,
"; endfunction");
316 if (fcn_name.length ())
324 error (
"dassl: incorrect number of elements in cell array");
327 if (! dassl_fcn && ! f_arg.
is_cell ())
333 switch (f_arg.
rows ())
339 fname =
"function y = ";
340 fname.append (fcn_name);
341 fname.append (
" (x, xdot, t) y = ");
343 fname,
"; endfunction");
353 fname =
"function y = ";
354 fname.append (fcn_name);
355 fname.append (
" (x, xdot, t) y = ");
357 fname,
"; endfunction");
362 jname =
"function jac = ";
363 jname.append (jac_name);
364 jname.append (
" (x, xdot, t, cj) jac = ");
371 if (fcn_name.length ())
386 ColumnVector deriv =
args(2).xvector_value (
"dassl: initial derivatives XDOT_0 must be a vector");
388 ColumnVector out_times =
args(3).xvector_value (
"dassl: output time variable T must be a vector");
391 int crit_times_set = 0;
394 crit_times =
args(4).xvector_value (
"dassl: list of critical times T_CRIT must be a vector");
400 error (
"dassl: X and XDOT_0 must have the same size");
402 double tzero = out_times (0);
408 DASSL dae (state, deriv, tzero, func);
416 output = dae.
integrate (out_times, deriv_output, crit_times);
418 output = dae.
integrate (out_times, deriv_output);
420 if (fcn_name.length ())
422 if (jac_name.length ())
435 error (
"dassl: %s", msg.c_str ());
std::string error_message(void) const
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
Matrix integrate(const ColumnVector &tout, Matrix &xdot_out)
OCTINTERP_API void print_usage(void)
octave_idx_type numel(void) const
Number of elements in the array.
octave_idx_type length(void) const
Matrix dassl_user_jacobian(const ColumnVector &x, const ColumnVector &xdot, double t, double cj)
void error(const char *fmt,...)
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function t
DEFUN(dassl, args, nargout, doc:)
static octave_function * dassl_jac
bool is_function_handle(void) const
std::string unique_symbol_name(const std::string &basename)
static DASSL_options dassl_opts
Cell cell_value(void) const
void clear_function(const std::string &nm)
void set_options(const DASSL_options &opt)
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 * dassl_fcn
bool is_inline_function(void) const
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
string_vector string_vector_value(bool pad=false) const
static uint32_t state[624]
octave_function * function_value(bool silent=false) const
static bool warned_fcn_imaginary
void warning(const char *fmt,...)
octave::unwind_protect frame
void err_user_supplied_eval(const char *name)
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)
ColumnVector dassl_user_function(const ColumnVector &x, const ColumnVector &xdot, double t, octave_idx_type &ires)
octave_idx_type integration_state(void) const
static bool warned_jac_imaginary
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
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
DAEFunc & set_jacobian_function(DAEJacFunc j)