annotate libinterp/corefcn/quad.cc @ 25080:699fe9cd51ca stable

quad.cc: Silence implicit-fallthrough warning bug #53542) * quad.cc (Fquad): Add OCTAVE_FALLTHROUGH to case of 4 input arguments.
author Rik <rik@octave.org>
date Sun, 01 Apr 2018 22:06:24 -0700
parents 6652d3823428
children cb1606f78f6b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
1 /*
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
2
25054
6652d3823428 maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 24728
diff changeset
3 Copyright (C) 1996-2018 John W. Eaton
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
4
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
6
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23826
diff changeset
7 Octave is free software: you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
8 under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23826
diff changeset
9 the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
10 (at your option) any later version.
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
11
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
12 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
13 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
15 GNU General Public License for more details.
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
16
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6741
diff changeset
18 along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23826
diff changeset
19 <https://www.gnu.org/licenses/>.
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
20
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
21 */
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
22
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
23 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21200
diff changeset
24 # include "config.h"
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
25 #endif
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
26
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
27 #include <string>
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
28
3567
dd8998699aa8 [project @ 2000-02-03 09:54:28 by jwe]
jwe
parents: 3544
diff changeset
29 #include <iomanip>
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3419
diff changeset
30 #include <iostream>
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
31
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
32 #include "Quad.h"
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
33 #include "lo-mappers.h"
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
34
15039
e753177cde93 maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents: 14854
diff changeset
35 #include "defun.h"
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
36 #include "error.h"
21100
e39e05d90788 Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents: 20940
diff changeset
37 #include "errwarn.h"
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
38 #include "pager.h"
23473
55916f99b8b6 prefer feval over do_multi_index_op
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
39 #include "parse.h"
20940
48b2ad5ee801 maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents: 20939
diff changeset
40 #include "ovl.h"
2968
e330cb788508 [project @ 1997-05-15 17:40:29 by jwe]
jwe
parents: 2928
diff changeset
41 #include "ov-fcn.h"
3243
dd00769643ae [project @ 1999-05-28 04:19:00 by jwe]
jwe
parents: 3131
diff changeset
42 #include "unwind-prot.h"
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
43 #include "utils.h"
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
44 #include "variables.h"
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
45
3998
f6df65db67f9 [project @ 2002-07-24 18:10:39 by jwe]
jwe
parents: 3964
diff changeset
46 #include "Quad-opts.cc"
f6df65db67f9 [project @ 2002-07-24 18:10:39 by jwe]
jwe
parents: 3964
diff changeset
47
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
48 // Global pointer for user defined function required by quadrature functions.
2968
e330cb788508 [project @ 1997-05-15 17:40:29 by jwe]
jwe
parents: 2928
diff changeset
49 static octave_function *quad_fcn;
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
50
4140
303b28a7a7e4 [project @ 2002-11-01 02:53:13 by jwe]
jwe
parents: 4122
diff changeset
51 // Have we warned about imaginary values returned from user function?
303b28a7a7e4 [project @ 2002-11-01 02:53:13 by jwe]
jwe
parents: 4122
diff changeset
52 static bool warned_imaginary = false;
303b28a7a7e4 [project @ 2002-11-01 02:53:13 by jwe]
jwe
parents: 4122
diff changeset
53
3243
dd00769643ae [project @ 1999-05-28 04:19:00 by jwe]
jwe
parents: 3131
diff changeset
54 // Is this a recursive call?
dd00769643ae [project @ 1999-05-28 04:19:00 by jwe]
jwe
parents: 3131
diff changeset
55 static int call_depth = 0;
dd00769643ae [project @ 1999-05-28 04:19:00 by jwe]
jwe
parents: 3131
diff changeset
56
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
57 double
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
58 quad_user_function (double x)
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
59 {
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
60 double retval = 0.0;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
61
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
62 octave_value_list args;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
63 args(0) = x;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
64
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
65 if (quad_fcn)
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
66 {
20725
7164a69472dd eliminate more uses of error state
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
67 octave_value_list tmp;
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
68
20725
7164a69472dd eliminate more uses of error state
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
69 try
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
70 {
23473
55916f99b8b6 prefer feval over do_multi_index_op
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
71 tmp = octave::feval (quad_fcn, args, 1);
20725
7164a69472dd eliminate more uses of error state
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
72 }
22327
d0562b3159c7 move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
73 catch (octave::execution_exception& e)
20725
7164a69472dd eliminate more uses of error state
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
74 {
21100
e39e05d90788 Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents: 20940
diff changeset
75 err_user_supplied_eval (e, "quad");
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
76 }
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
77
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
78 if (! tmp.length () || ! tmp(0).is_defined ())
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
79 err_user_supplied_eval ("quad");
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
80
23581
c3075ae020e1 maint: Deprecate is_complex_type and replace with iscomplex.
Rik <rik@octave.org>
parents: 23473
diff changeset
81 if (! warned_imaginary && tmp(0).iscomplex ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
82 {
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
83 warning ("quad: ignoring imaginary part returned from user-supplied function");
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
84 warned_imaginary = true;
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
85 }
4140
303b28a7a7e4 [project @ 2002-11-01 02:53:13 by jwe]
jwe
parents: 4122
diff changeset
86
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
87 retval = tmp(0).xdouble_value ("quad: expecting user supplied function to return numeric value");
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
88 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
89
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
90 return retval;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
91 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
92
7805
62affb34e648 Make quad work with single precision
David Bateman <dbateman@free.fr>
parents: 7562
diff changeset
93 float
62affb34e648 Make quad work with single precision
David Bateman <dbateman@free.fr>
parents: 7562
diff changeset
94 quad_float_user_function (float x)
62affb34e648 Make quad work with single precision
David Bateman <dbateman@free.fr>
parents: 7562
diff changeset
95 {
62affb34e648 Make quad work with single precision
David Bateman <dbateman@free.fr>
parents: 7562
diff changeset
96 float retval = 0.0;
62affb34e648 Make quad work with single precision
David Bateman <dbateman@free.fr>
parents: 7562
diff changeset
97
62affb34e648 Make quad work with single precision
David Bateman <dbateman@free.fr>
parents: 7562
diff changeset
98 octave_value_list args;
62affb34e648 Make quad work with single precision
David Bateman <dbateman@free.fr>
parents: 7562
diff changeset
99 args(0) = x;
62affb34e648 Make quad work with single precision
David Bateman <dbateman@free.fr>
parents: 7562
diff changeset
100
62affb34e648 Make quad work with single precision
David Bateman <dbateman@free.fr>
parents: 7562
diff changeset
101 if (quad_fcn)
62affb34e648 Make quad work with single precision
David Bateman <dbateman@free.fr>
parents: 7562
diff changeset
102 {
20725
7164a69472dd eliminate more uses of error state
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
103 octave_value_list tmp;
7805
62affb34e648 Make quad work with single precision
David Bateman <dbateman@free.fr>
parents: 7562
diff changeset
104
20725
7164a69472dd eliminate more uses of error state
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
105 try
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
106 {
23473
55916f99b8b6 prefer feval over do_multi_index_op
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
107 tmp = octave::feval (quad_fcn, args, 1);
20725
7164a69472dd eliminate more uses of error state
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
108 }
22327
d0562b3159c7 move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
109 catch (octave::execution_exception& e)
20725
7164a69472dd eliminate more uses of error state
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
110 {
21100
e39e05d90788 Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents: 20940
diff changeset
111 err_user_supplied_eval (e, "quad");
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
112 }
7805
62affb34e648 Make quad work with single precision
David Bateman <dbateman@free.fr>
parents: 7562
diff changeset
113
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
114 if (! tmp.length () || ! tmp(0).is_defined ())
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
115 err_user_supplied_eval ("quad");
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
116
23581
c3075ae020e1 maint: Deprecate is_complex_type and replace with iscomplex.
Rik <rik@octave.org>
parents: 23473
diff changeset
117 if (! warned_imaginary && tmp(0).iscomplex ())
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
118 {
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
119 warning ("quad: ignoring imaginary part returned from user-supplied function");
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
120 warned_imaginary = true;
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
121 }
7805
62affb34e648 Make quad work with single precision
David Bateman <dbateman@free.fr>
parents: 7562
diff changeset
122
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21100
diff changeset
123 retval = tmp(0).xfloat_value ("quad: expecting user supplied function to return numeric value");
7805
62affb34e648 Make quad work with single precision
David Bateman <dbateman@free.fr>
parents: 7562
diff changeset
124 }
62affb34e648 Make quad work with single precision
David Bateman <dbateman@free.fr>
parents: 7562
diff changeset
125
62affb34e648 Make quad work with single precision
David Bateman <dbateman@free.fr>
parents: 7562
diff changeset
126 return retval;
62affb34e648 Make quad work with single precision
David Bateman <dbateman@free.fr>
parents: 7562
diff changeset
127 }
62affb34e648 Make quad work with single precision
David Bateman <dbateman@free.fr>
parents: 7562
diff changeset
128
24728
af11cc7cd336 use DEFMETHODX instead of undefining quad
John W. Eaton <jwe@octave.org>
parents: 24546
diff changeset
129 DEFMETHODX ("quad", Fquad, interp, args, ,
af11cc7cd336 use DEFMETHODX instead of undefining quad
John W. Eaton <jwe@octave.org>
parents: 24546
diff changeset
130 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
131 @deftypefn {} {@var{q} =} quad (@var{f}, @var{a}, @var{b})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
132 @deftypefnx {} {@var{q} =} quad (@var{f}, @var{a}, @var{b}, @var{tol})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
133 @deftypefnx {} {@var{q} =} quad (@var{f}, @var{a}, @var{b}, @var{tol}, @var{sing})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
134 @deftypefnx {} {[@var{q}, @var{ier}, @var{nfun}, @var{err}] =} quad (@dots{})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
135 Numerically evaluate the integral of @var{f} from @var{a} to @var{b} using
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
136 Fortran routines from @w{@sc{quadpack}}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
137
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
138 @var{f} is a function handle, inline function, or a string containing the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
139 name of the function to evaluate. The function must have the form @code{y =
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
140 f (x)} where @var{y} and @var{x} are scalars.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
141
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
142 @var{a} and @var{b} are the lower and upper limits of integration. Either
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
143 or both may be infinite.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
144
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
145 The optional argument @var{tol} is a vector that specifies the desired
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
146 accuracy of the result. The first element of the vector is the desired
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
147 absolute tolerance, and the second element is the desired relative
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
148 tolerance. To choose a relative test only, set the absolute
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
149 tolerance to zero. To choose an absolute test only, set the relative
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
150 tolerance to zero. Both tolerances default to @code{sqrt (eps)} or
24545
ba8b828ee4f2 doc: Replace @math{1e^{XXX}} sequences with raw 1eXXX (bug #52827).
Rik <rik@octave.org>
parents: 23219
diff changeset
151 approximately 1.5e-8.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
152
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
153 The optional argument @var{sing} is a vector of values at which the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
154 integrand is known to be singular.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
155
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
156 The result of the integration is returned in @var{q}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
157
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
158 @var{ier} contains an integer error code (0 indicates a successful
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
159 integration).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
160
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
161 @var{nfun} indicates the number of function evaluations that were
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
162 made.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
163
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
164 @var{err} contains an estimate of the error in the solution.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
165
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
166 The function @code{quad_options} can set other optional parameters for
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
167 @code{quad}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
168
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
169 Note: because @code{quad} is written in Fortran it cannot be called
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
170 recursively. This prevents its use in integrating over more than one
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
171 variable by routines @code{dblquad} and @code{triplequad}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
172 @seealso{quad_options, quadv, quadl, quadgk, quadcc, trapz, dblquad, triplequad}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
173 @end deftypefn */)
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
174 {
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20915
diff changeset
175 int nargin = args.length ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
176
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20915
diff changeset
177 if (nargin < 3 || nargin > 5)
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20915
diff changeset
178 print_usage ();
4954
ed0f3cb6d3d4 [project @ 2004-09-01 21:24:53 by jwe]
jwe
parents: 4140
diff changeset
179
4140
303b28a7a7e4 [project @ 2002-11-01 02:53:13 by jwe]
jwe
parents: 4122
diff changeset
180 warned_imaginary = false;
303b28a7a7e4 [project @ 2002-11-01 02:53:13 by jwe]
jwe
parents: 4122
diff changeset
181
21743
f4d7d0eb5b0c use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
182 octave::unwind_protect frame;
3243
dd00769643ae [project @ 1999-05-28 04:19:00 by jwe]
jwe
parents: 3131
diff changeset
183
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9377
diff changeset
184 frame.protect_var (call_depth);
3243
dd00769643ae [project @ 1999-05-28 04:19:00 by jwe]
jwe
parents: 3131
diff changeset
185 call_depth++;
dd00769643ae [project @ 1999-05-28 04:19:00 by jwe]
jwe
parents: 3131
diff changeset
186
dd00769643ae [project @ 1999-05-28 04:19:00 by jwe]
jwe
parents: 3131
diff changeset
187 if (call_depth > 1)
20709
a2a99aaf680b eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20687
diff changeset
188 error ("quad: invalid recursive call");
3243
dd00769643ae [project @ 1999-05-28 04:19:00 by jwe]
jwe
parents: 3131
diff changeset
189
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20915
diff changeset
190 std::string fcn_name;
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
191
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
192 if (args(0).is_function_handle () || args(0).is_inline_function ())
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
193 quad_fcn = args(0).function_value ();
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
194 else
3243
dd00769643ae [project @ 1999-05-28 04:19:00 by jwe]
jwe
parents: 3131
diff changeset
195 {
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
196 fcn_name = unique_symbol_name ("__quad_fcn__");
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
197 std::string fname = "function y = ";
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
198 fname.append (fcn_name);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
199 fname.append ("(x) y = ");
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
200 quad_fcn = extract_function (args(0), "quad", fcn_name, fname,
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
201 "; endfunction");
23699
b29904962d2d deprecate some global functions that access the symbol table
John W. Eaton <jwe@octave.org>
parents: 23581
diff changeset
202 octave::symbol_table& symtab = interp.get_symbol_table ();
b29904962d2d deprecate some global functions that access the symbol table
John W. Eaton <jwe@octave.org>
parents: 23581
diff changeset
203 frame.add_method (symtab, &octave::symbol_table::clear_function, fcn_name);
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
204 }
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
205
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
206 if (! quad_fcn)
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
207 error ("quad: FCN argument is not a valid function name or handle");
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
208
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20915
diff changeset
209 octave_value_list retval;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20915
diff changeset
210
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
211 if (args(1).is_single_type () || args(2).is_single_type ())
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
212 {
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
213 float a = args(1).xfloat_value ("quad: lower limit of integration A must be a scalar");
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
214 float b = args(2).xfloat_value ("quad: upper limit of integration B must be a scalar");
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
215
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
216 int indefinite = 0;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
217 FloatIndefQuad::IntegralType indef_type
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
218 = FloatIndefQuad::doubly_infinite;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
219 float bound = 0.0;
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
220 if (octave::math::isinf (a) && octave::math::isinf (b))
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
221 {
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
222 indefinite = 1;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
223 indef_type = FloatIndefQuad::doubly_infinite;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
224 }
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
225 else if (octave::math::isinf (a))
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
226 {
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
227 indefinite = 1;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
228 bound = b;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
229 indef_type = FloatIndefQuad::neg_inf_to_bound;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
230 }
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
231 else if (octave::math::isinf (b))
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
232 {
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
233 indefinite = 1;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
234 bound = a;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
235 indef_type = FloatIndefQuad::bound_to_inf;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
236 }
4954
ed0f3cb6d3d4 [project @ 2004-09-01 21:24:53 by jwe]
jwe
parents: 4140
diff changeset
237
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
238 octave_idx_type ier = 0;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
239 octave_idx_type nfun = 0;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
240 float abserr = 0.0;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
241 float val = 0.0;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
242 bool have_sing = false;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
243 FloatColumnVector sing;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
244 FloatColumnVector tol;
3243
dd00769643ae [project @ 1999-05-28 04:19:00 by jwe]
jwe
parents: 3131
diff changeset
245
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
246 switch (nargin)
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
247 {
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
248 case 5:
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
249 if (indefinite)
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
250 error ("quad: singularities not allowed on infinite intervals");
7805
62affb34e648 Make quad work with single precision
David Bateman <dbateman@free.fr>
parents: 7562
diff changeset
251
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
252 have_sing = true;
7805
62affb34e648 Make quad work with single precision
David Bateman <dbateman@free.fr>
parents: 7562
diff changeset
253
22173
8de49f15e182 doc: Fix "doubled words" typos (\b(\w+)\s+\1\b)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 21966
diff changeset
254 sing = args(4).xfloat_vector_value ("quad: fifth argument SING must be a vector of singularities");
23826
d69021d58a61 avoid fallthrough warnings
John W. Eaton <jwe@octave.org>
parents: 23699
diff changeset
255 OCTAVE_FALLTHROUGH;
7805
62affb34e648 Make quad work with single precision
David Bateman <dbateman@free.fr>
parents: 7562
diff changeset
256
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
257 case 4:
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
258 tol = args(3).xfloat_vector_value ("quad: TOL must be a 1 or 2-element vector");
3243
dd00769643ae [project @ 1999-05-28 04:19:00 by jwe]
jwe
parents: 3131
diff changeset
259
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
260 switch (tol.numel ())
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
261 {
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
262 case 2:
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
263 quad_opts.set_single_precision_relative_tolerance (tol (1));
23826
d69021d58a61 avoid fallthrough warnings
John W. Eaton <jwe@octave.org>
parents: 23699
diff changeset
264 OCTAVE_FALLTHROUGH;
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
265
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
266 case 1:
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
267 quad_opts.set_single_precision_absolute_tolerance (tol (0));
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
268 break;
3243
dd00769643ae [project @ 1999-05-28 04:19:00 by jwe]
jwe
parents: 3131
diff changeset
269
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
270 default:
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
271 error ("quad: TOL must be a 1 or 2-element vector");
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
272 }
25080
699fe9cd51ca quad.cc: Silence implicit-fallthrough warning bug #53542)
Rik <rik@octave.org>
parents: 25054
diff changeset
273 OCTAVE_FALLTHROUGH;
3243
dd00769643ae [project @ 1999-05-28 04:19:00 by jwe]
jwe
parents: 3131
diff changeset
274
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
275 case 3:
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
276 if (indefinite)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
277 {
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
278 FloatIndefQuad iq (quad_float_user_function, bound,
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
279 indef_type);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
280 iq.set_options (quad_opts);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
281 val = iq.float_integrate (ier, nfun, abserr);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
282 }
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
283 else
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
284 {
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
285 if (have_sing)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
286 {
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
287 FloatDefQuad dq (quad_float_user_function, a, b, sing);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
288 dq.set_options (quad_opts);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
289 val = dq.float_integrate (ier, nfun, abserr);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
290 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
291 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
292 {
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
293 FloatDefQuad dq (quad_float_user_function, a, b);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
294 dq.set_options (quad_opts);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
295 val = dq.float_integrate (ier, nfun, abserr);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
296 }
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
297 }
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
298 break;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
299
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
300 default:
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
301 panic_impossible ();
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
302 break;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
303 }
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
304
20884
f1b2a2dbc0e1 2015 Code Sprint: use ovl () in C++ files.
José Luis García Pallero <jgpallero@gmail.com>
parents: 20853
diff changeset
305 retval = ovl (val, ier, nfun, abserr);
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
306
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
307 }
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
308 else
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
309 {
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
310 double a = args(1).xdouble_value ("quad: lower limit of integration A must be a scalar");
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
311 double b = args(2).xdouble_value ("quad: upper limit of integration B must be a scalar");
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
312
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
313 int indefinite = 0;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
314 IndefQuad::IntegralType indef_type = IndefQuad::doubly_infinite;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
315 double bound = 0.0;
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
316 if (octave::math::isinf (a) && octave::math::isinf (b))
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
317 {
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
318 indefinite = 1;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
319 indef_type = IndefQuad::doubly_infinite;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
320 }
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
321 else if (octave::math::isinf (a))
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
322 {
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
323 indefinite = 1;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
324 bound = b;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
325 indef_type = IndefQuad::neg_inf_to_bound;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
326 }
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21743
diff changeset
327 else if (octave::math::isinf (b))
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
328 {
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
329 indefinite = 1;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
330 bound = a;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
331 indef_type = IndefQuad::bound_to_inf;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
332 }
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
333
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
334 octave_idx_type ier = 0;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
335 octave_idx_type nfun = 0;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
336 double abserr = 0.0;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
337 double val = 0.0;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
338 bool have_sing = false;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
339 ColumnVector sing;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
340 ColumnVector tol;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
341
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
342 switch (nargin)
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
343 {
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
344 case 5:
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
345 if (indefinite)
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
346 error ("quad: singularities not allowed on infinite intervals");
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
347
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
348 have_sing = true;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
349
22173
8de49f15e182 doc: Fix "doubled words" typos (\b(\w+)\s+\1\b)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 21966
diff changeset
350 sing = args(4).vector_value ("quad: fifth argument SING must be a vector of singularities");
23826
d69021d58a61 avoid fallthrough warnings
John W. Eaton <jwe@octave.org>
parents: 23699
diff changeset
351 OCTAVE_FALLTHROUGH;
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
352
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
353 case 4:
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
354 tol = args(3).xvector_value ("quad: TOL must be a 1 or 2-element vector");
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
355
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
356 switch (tol.numel ())
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
357 {
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
358 case 2:
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
359 quad_opts.set_relative_tolerance (tol (1));
23826
d69021d58a61 avoid fallthrough warnings
John W. Eaton <jwe@octave.org>
parents: 23699
diff changeset
360 OCTAVE_FALLTHROUGH;
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
361
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
362 case 1:
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
363 quad_opts.set_absolute_tolerance (tol (0));
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
364 break;
3243
dd00769643ae [project @ 1999-05-28 04:19:00 by jwe]
jwe
parents: 3131
diff changeset
365
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
366 default:
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
367 error ("quad: TOL must be a 1 or 2-element vector");
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
368 }
25080
699fe9cd51ca quad.cc: Silence implicit-fallthrough warning bug #53542)
Rik <rik@octave.org>
parents: 25054
diff changeset
369 OCTAVE_FALLTHROUGH;
3243
dd00769643ae [project @ 1999-05-28 04:19:00 by jwe]
jwe
parents: 3131
diff changeset
370
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
371 case 3:
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
372 if (indefinite)
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
373 {
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
374 IndefQuad iq (quad_user_function, bound, indef_type);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
375 iq.set_options (quad_opts);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
376 val = iq.integrate (ier, nfun, abserr);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
377 }
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
378 else
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
379 {
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
380 if (have_sing)
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
381 {
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
382 DefQuad dq (quad_user_function, a, b, sing);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
383 dq.set_options (quad_opts);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
384 val = dq.integrate (ier, nfun, abserr);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
385 }
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
386 else
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
387 {
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
388 DefQuad dq (quad_user_function, a, b);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
389 dq.set_options (quad_opts);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
390 val = dq.integrate (ier, nfun, abserr);
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
391 }
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
392 }
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
393 break;
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
394
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
395 default:
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
396 panic_impossible ();
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
397 break;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10066
diff changeset
398 }
4954
ed0f3cb6d3d4 [project @ 2004-09-01 21:24:53 by jwe]
jwe
parents: 4140
diff changeset
399
20884
f1b2a2dbc0e1 2015 Code Sprint: use ovl () in C++ files.
José Luis García Pallero <jgpallero@gmail.com>
parents: 20853
diff changeset
400 retval = ovl (val, ier, nfun, abserr);
3243
dd00769643ae [project @ 1999-05-28 04:19:00 by jwe]
jwe
parents: 3131
diff changeset
401 }
20802
8bb38ba1bad6 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20785
diff changeset
402
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
403 return retval;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
404 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
405
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
406 /*
14085
4e8f23ccadce test: Use internal prefix "__" for %!functions to avoid polluting workspace
Rik <octave@nomad.inbox5.com>
parents: 13915
diff changeset
407 %!function y = __f (x)
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
408 %! y = x + 1;
14085
4e8f23ccadce test: Use internal prefix "__" for %!functions to avoid polluting workspace
Rik <octave@nomad.inbox5.com>
parents: 13915
diff changeset
409 %!endfunction
4e8f23ccadce test: Use internal prefix "__" for %!functions to avoid polluting workspace
Rik <octave@nomad.inbox5.com>
parents: 13915
diff changeset
410
7562
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
411 %!test
14085
4e8f23ccadce test: Use internal prefix "__" for %!functions to avoid polluting workspace
Rik <octave@nomad.inbox5.com>
parents: 13915
diff changeset
412 %! [v, ier, nfun, err] = quad ("__f", 0, 5);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
413 %! assert (ier, 0);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
414 %! assert (v, 17.5, sqrt (eps));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
415 %! assert (nfun > 0);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
416 %! assert (err < sqrt (eps));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
417
7805
62affb34e648 Make quad work with single precision
David Bateman <dbateman@free.fr>
parents: 7562
diff changeset
418 %!test
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
419 %! [v, ier, nfun, err] = quad ("__f", single (0), single (5));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
420 %! assert (ier, 0);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
421 %! assert (v, 17.5, sqrt (eps ("single")));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
422 %! assert (nfun > 0);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
423 %! assert (err < sqrt (eps ("single")));
7562
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
424
14085
4e8f23ccadce test: Use internal prefix "__" for %!functions to avoid polluting workspace
Rik <octave@nomad.inbox5.com>
parents: 13915
diff changeset
425 %!function y = __f (x)
7562
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
426 %! y = x .* sin (1 ./ x) .* sqrt (abs (1 - x));
14085
4e8f23ccadce test: Use internal prefix "__" for %!functions to avoid polluting workspace
Rik <octave@nomad.inbox5.com>
parents: 13915
diff changeset
427 %!endfunction
4e8f23ccadce test: Use internal prefix "__" for %!functions to avoid polluting workspace
Rik <octave@nomad.inbox5.com>
parents: 13915
diff changeset
428
7562
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
429 %!test
14085
4e8f23ccadce test: Use internal prefix "__" for %!functions to avoid polluting workspace
Rik <octave@nomad.inbox5.com>
parents: 13915
diff changeset
430 %! [v, ier, nfun, err] = quad ("__f", 0.001, 3);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
431 %! assert (ier == 0 || ier == 1);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
432 %! assert (v, 1.98194120273598, sqrt (eps));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
433 %! assert (nfun > 0);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
434
7805
62affb34e648 Make quad work with single precision
David Bateman <dbateman@free.fr>
parents: 7562
diff changeset
435 %!test
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
436 %! [v, ier, nfun, err] = quad ("__f", single (0.001), single (3));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
437 %! assert (ier == 0 || ier == 1);
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
438 %! assert (v, 1.98194120273598, sqrt (eps ("single")));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
439 %! assert (nfun > 0);
7562
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
440
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
441 %!error quad ()
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
442 %!error quad ("__f", 1, 2, 3, 4, 5)
7562
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
443
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
444 %!test
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
445 %! quad_options ("absolute tolerance", eps);
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
446 %! assert (quad_options ("absolute tolerance") == eps);
7562
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
447
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
448 %!error quad_options (1, 2, 3)
7562
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
449 */