26 #if defined (HAVE_CONFIG_H)
61 static bool warned_fcn_imaginary =
false;
62 static bool warned_jac_imaginary =
false;
65 static int call_depth = 0;
84 tmp = interp.
feval (lsode_fcn, args, 1);
86 catch (octave::execution_exception& ee)
91 if (tmp.
empty () || ! tmp(0).is_defined ())
94 if (! warned_fcn_imaginary && tmp(0).iscomplex ())
96 warning (
"lsode: ignoring imaginary part returned from user-supplied function");
97 warned_fcn_imaginary =
true;
100 retval = tmp(0).xvector_value (
"lsode: expecting user supplied function to return numeric vector");
126 tmp = interp.
feval (lsode_jac, args, 1);
128 catch (octave::execution_exception& ee)
133 if (tmp.
empty () || ! tmp(0).is_defined ())
136 if (! warned_jac_imaginary && tmp(0).iscomplex ())
138 warning (
"lsode: ignoring imaginary part returned from user-supplied jacobian function");
139 warned_jac_imaginary =
true;
142 retval = tmp(0).xmatrix_value (
"lsode: expecting user supplied jacobian function to return numeric array");
286 int nargin = args.
length ();
288 if (nargin < 3 || nargin > 4)
291 warned_fcn_imaginary =
false;
292 warned_jac_imaginary =
false;
298 error (
"lsode: invalid recursive call");
302 std::string fcn_name, fname, jac_name, jname;
309 std::list<std::string> parameter_names ({
"x",
"t"});
316 else if (c.
numel () == 2)
329 error (
"lsode: incorrect number of elements in cell array");
338 switch (f_arg.
rows ())
363 error (
"lsode: first arg should be a string or 2-element string array");
369 error (
"lsode: FCN argument is not a valid function name or handle");
371 ColumnVector state = args(1).xvector_value (
"lsode: initial state X_0 must be a vector");
372 ColumnVector out_times = args(2).xvector_value (
"lsode: output time variable T must be a vector");
376 int crit_times_set = 0;
379 crit_times = args(3).xvector_value (
"lsode: list of critical times T_CRIT must be a vector");
384 double tzero = out_times (0);
386 ODEFunc fcn (lsode_user_function);
391 LSODE ode (state, tzero, fcn);
397 output = ode.
integrate (out_times, crit_times);
401 if (fcn_name.length ())
403 if (jac_name.length ())
412 else if (nargout < 2)
413 error (
"lsode: %s", msg.c_str ());
497 OCTAVE_END_NAMESPACE(
octave)
bool isempty() const
Size of the specified dimension.
octave_idx_type numel() const
Number of elements in the array.
void set_options(const LSODE_options &opt)
std::string error_message() const
ODEFunc & set_jacobian_function(ODEJacFunc j)
virtual ColumnVector integrate(double tt)
octave_idx_type integration_state() const
bool integration_ok() const
symbol_table & get_symbol_table()
octave_value_list feval(const char *name, const octave_value_list &args=octave_value_list(), int nargout=0)
Evaluate an Octave function (built-in or interpreted) and return the list of result values.
octave_idx_type length() const
bool is_function_handle() const
bool is_undefined() const
bool is_inline_function() const
octave_idx_type rows() const
string_vector string_vector_value(bool pad=false) const
void clear_function(const std::string &name)
void warning(const char *fmt,...)
void() error(const char *fmt,...)
void err_user_supplied_eval(const char *name)
interpreter & __get_interpreter__()
octave_value get_function_handle(interpreter &interp, const octave_value &arg, const std::string ¶meter_name)
F77_RET_T const F77_DBLE * x
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value lsode_fcn
DEFMETHOD(lsode, interp, args, nargout, doc:)
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))