26 #if defined (HAVE_CONFIG_H)
58 static bool warned_fcn_imaginary =
false;
59 static bool warned_jac_imaginary =
false;
62 static int call_depth = 0;
86 tmp = interp.
feval (dassl_fcn, args, 1);
94 if (tlen == 0 || ! tmp(0).is_defined ())
97 if (! warned_fcn_imaginary && tmp(0).iscomplex ())
99 warning (
"dassl: ignoring imaginary part returned from user-supplied function");
100 warned_fcn_imaginary =
true;
103 retval = tmp(0).vector_value ();
106 ires = tmp(1).int_value ();
138 tmp = interp.
feval (dassl_jac, args, 1);
146 if (tlen == 0 || ! tmp(0).is_defined ())
149 if (! warned_jac_imaginary && tmp(0).iscomplex ())
151 warning (
"dassl: ignoring imaginary part returned from user-supplied jacobian function");
152 warned_jac_imaginary =
true;
155 retval = tmp(0).matrix_value ();
268 int nargin = args.
length ();
270 if (nargin < 4 || nargin > 5)
273 warned_fcn_imaginary =
false;
274 warned_jac_imaginary =
false;
282 error (
"dassl: invalid recursive call");
284 std::string fcn_name, fname, jac_name, jname;
291 std::list<std::string> fcn_param_names ({
"x",
"xdot",
"t"});
292 std::list<std::string> jac_param_names ({
"x",
"xdot",
"t",
"cj"});
299 else if (c.
numel () == 2)
312 error (
"dassl: incorrect number of elements in cell array");
321 switch (f_arg.
rows ())
346 error (
"dassl: first arg should be a string or 2-element string array");
352 error (
"dassl: FCN argument is not a valid function name or handle");
354 ColumnVector state = args(1).xvector_value (
"dassl: initial state X_0 must be a vector");
356 ColumnVector deriv = args(2).xvector_value (
"dassl: initial derivatives XDOT_0 must be a vector");
358 ColumnVector out_times = args(3).xvector_value (
"dassl: output time variable T must be a vector");
361 int crit_times_set = 0;
364 crit_times = args(4).xvector_value (
"dassl: list of critical times T_CRIT must be a vector");
370 error (
"dassl: X and XDOT_0 must have the same size");
372 double tzero = out_times (0);
374 DAEFunc fcn (dassl_user_function);
378 DASSL dae (state, deriv, tzero, fcn);
386 output = dae.
integrate (out_times, deriv_output, crit_times);
388 output = dae.
integrate (out_times, deriv_output);
395 retval(1) = deriv_output;
400 error (
"dassl: %s", msg.c_str ());
498 OCTAVE_END_NAMESPACE(
octave)
bool isempty() const
Size of the specified dimension.
octave_idx_type numel() const
Number of elements in the array.
DAEFunc & set_jacobian_function(DAEJacFunc j)
void set_options(const DASSL_options &opt)
std::string error_message() const
Matrix integrate(const ColumnVector &tout, Matrix &xdot_out)
octave_idx_type integration_state() const
bool integration_ok() const
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
DEFMETHOD(dassl, interp, args, nargout, doc:)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value dassl_fcn
void warning(const char *fmt,...)
void() error(const char *fmt,...)
#define error_unless(cond)
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
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))