26 #if defined (HAVE_CONFIG_H)
59 static bool warned_fcn_imaginary =
false;
60 static bool warned_jac_imaginary =
false;
63 static int call_depth = 0;
87 tmp = interp.
feval (daspk_fcn, args, 1);
95 if (tlen == 0 || ! tmp(0).is_defined ())
98 if (! warned_fcn_imaginary && tmp(0).iscomplex ())
100 warning (
"daspk: ignoring imaginary part returned from user-supplied function");
101 warned_fcn_imaginary =
true;
104 retval = tmp(0).vector_value ();
107 ires = tmp(1).idx_type_value ();
139 tmp = interp.
feval (daspk_jac, args, 1);
147 if (tlen == 0 || ! tmp(0).is_defined ())
150 if (! warned_jac_imaginary && tmp(0).iscomplex ())
152 warning (
"daspk: ignoring imaginary part returned from user-supplied jacobian function");
153 warned_jac_imaginary =
true;
156 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 (
"daspk: 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 (
"daspk: incorrect number of elements in cell array");
321 switch (f_arg.
rows ())
346 error (
"daspk: first arg should be a string or 2-element string array");
352 error (
"daspk: FCN argument is not a valid function name or handle");
354 ColumnVector state = args(1).xvector_value (
"daspk: initial state X_0 must be a vector");
356 ColumnVector deriv = args(2).xvector_value (
"daspk: initial derivatives XDOT_0 must be a vector");
358 ColumnVector out_times = args(3).xvector_value (
"daspk: output time variable T must be a vector");
361 int crit_times_set = 0;
364 crit_times = args(4).xvector_value (
"daspk: list of critical times T_CRIT must be a vector");
370 error (
"daspk: X_0 and XDOT_0 must have the same size");
372 double tzero = out_times (0);
374 DAEFunc fcn (daspk_user_function);
378 DASPK dae (state, deriv, tzero, fcn);
385 output = dae.
integrate (out_times, deriv_output, crit_times);
387 output = dae.
integrate (out_times, deriv_output);
394 retval(1) = deriv_output;
399 error (
"daspk: %s", msg.c_str ());
411 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 DASPK_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
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
DEFMETHOD(daspk, interp, args, nargout, doc:)
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()) ? '\'' :'"'))