26 #if defined (HAVE_CONFIG_H)
55 static bool warned_imaginary =
false;
58 static int call_depth = 0;
61 quad_user_function (
double x)
76 tmp = interp.
feval (quad_fcn, args, 1);
83 if (! tmp.
length () || ! tmp(0).is_defined ())
86 if (! warned_imaginary && tmp(0).iscomplex ())
88 warning (
"quad: ignoring imaginary part returned from user-supplied function");
89 warned_imaginary =
true;
92 retval = tmp(0).xdouble_value (
"quad: expecting user supplied function to return numeric value");
99 quad_float_user_function (
float x)
114 tmp = interp.
feval (quad_fcn, args, 1);
121 if (! tmp.
length () || ! tmp(0).is_defined ())
124 if (! warned_imaginary && tmp(0).iscomplex ())
126 warning (
"quad: ignoring imaginary part returned from user-supplied function");
127 warned_imaginary =
true;
130 retval = tmp(0).xfloat_value (
"quad: expecting user supplied function to return numeric value");
182 int nargin = args.
length ();
184 if (nargin < 3 || nargin > 5)
187 warned_imaginary =
false;
193 error (
"quad: invalid recursive call");
199 if (args(1).is_single_type () || args(2).is_single_type ())
201 float a = args(1).xfloat_value (
"quad: lower limit of integration A must be a scalar");
202 float b = args(2).xfloat_value (
"quad: upper limit of integration B must be a scalar");
230 bool have_sing =
false;
238 error (
"quad: singularities not allowed on infinite intervals");
242 sing = args(4).xfloat_vector_value (
"quad: fifth argument SING must be a vector of singularities");
246 tol = args(3).xfloat_vector_value (
"quad: TOL must be a 1 or 2-element vector");
248 switch (tol.
numel ())
251 quad_opts.set_single_precision_relative_tolerance (tol (1));
255 quad_opts.set_single_precision_absolute_tolerance (tol (0));
259 error (
"quad: TOL must be a 1 or 2-element vector");
293 retval =
ovl (val, ier, nfev, abserr);
298 double a = args(1).xdouble_value (
"quad: lower limit of integration A must be a scalar");
299 double b = args(2).xdouble_value (
"quad: upper limit of integration B must be a scalar");
326 bool have_sing =
false;
334 error (
"quad: singularities not allowed on infinite intervals");
338 sing = args(4).xvector_value (
"quad: fifth argument SING must be a vector of singularities");
342 tol = args(3).xvector_value (
"quad: TOL must be a 1 or 2-element vector");
344 switch (tol.
numel ())
347 quad_opts.set_relative_tolerance (tol (1));
351 quad_opts.set_absolute_tolerance (tol (0));
355 error (
"quad: TOL must be a 1 or 2-element vector");
362 IndefQuad iq (quad_user_function, bound, indef_type);
370 DefQuad dq (quad_user_function, a, b, sing);
376 DefQuad dq (quad_user_function, a, b);
388 retval =
ovl (val, ier, nfev, abserr);
466 OCTAVE_END_NAMESPACE(
octave)
octave_value_list Fquad(octave::interpreter &, const octave_value_list &=octave_value_list(), int=0)
octave_idx_type numel() const
Number of elements in the array.
void set_options(const Quad_options &opt)
virtual float float_integrate()
virtual double integrate()
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
void warning(const char *fmt,...)
void() error(const char *fmt,...)
#define panic_impossible()
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_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
DEFMETHODX("quad", Fquad, interp, args,, doc:)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value quad_fcn