Mercurial > octave
annotate liboctave/numeric/Quad.cc @ 30564:796f54d4ddbf stable
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2021.
In all .txi and .texi files except gpl.txi and gpl.texi in the
doc/liboctave and doc/interpreter directories, change the copyright
to "Octave Project Developers", the same as used for other source
files. Update copyright notices for 2022 (not done since 2019). For
gpl.txi and gpl.texi, change the copyright notice to be "Free Software
Foundation, Inc." and leave the date at 2007 only because this file
only contains the text of the GPL, not anything created by the Octave
Project Developers.
Add Paul Thomas to contributors.in.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 28 Dec 2021 18:22:40 -0500 |
parents | f3f3e3793fb5 |
children | 597f3ee61a48 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30394
diff
changeset
|
3 // Copyright (C) 1993-2022 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
3 | 25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21202
diff
changeset
|
27 # include "config.h" |
3 | 28 #endif |
29 | |
23475
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
30 #include <cassert> |
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
31 |
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
32 #include "Array.h" |
3 | 33 #include "Quad.h" |
1847 | 34 #include "f77-fcn.h" |
2292 | 35 #include "lo-error.h" |
4180 | 36 #include "quit.h" |
3 | 37 |
38 static integrand_fcn user_fcn; | |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
39 static float_integrand_fcn float_user_fcn; |
3 | 40 |
25681
bef21ac72618
eliminate unnecessary sun-utils.h header file
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
41 typedef F77_INT (*quad_fcn_ptr) (const double&, int&, double&); |
bef21ac72618
eliminate unnecessary sun-utils.h header file
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
42 typedef F77_INT (*quad_float_fcn_ptr) (const float&, int&, float&); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
43 |
3 | 44 extern "C" |
4552 | 45 { |
46 F77_RET_T | |
22133
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
47 F77_FUNC (dqagp, DQAGP) (quad_fcn_ptr, const F77_DBLE&, const F77_DBLE&, |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30101
diff
changeset
|
48 const F77_INT&, const F77_DBLE *, |
22133
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
49 const F77_DBLE&, const F77_DBLE&, F77_DBLE&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
50 F77_DBLE&, F77_INT&, F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
51 const F77_INT&, const F77_INT&, |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30101
diff
changeset
|
52 F77_INT&, F77_INT *, F77_DBLE *); |
3 | 53 |
4552 | 54 F77_RET_T |
22133
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
55 F77_FUNC (dqagi, DQAGI) (quad_fcn_ptr, const F77_DBLE&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
56 const F77_INT&, const F77_DBLE&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
57 const F77_DBLE&, F77_DBLE&, F77_DBLE&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
58 F77_INT&, F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
59 const F77_INT&, const F77_INT&, |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30101
diff
changeset
|
60 F77_INT&, F77_INT *, F77_DBLE *); |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
61 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
62 F77_RET_T |
22133
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
63 F77_FUNC (qagp, QAGP) (quad_float_fcn_ptr, const F77_REAL&, const F77_REAL&, |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30101
diff
changeset
|
64 const F77_INT&, const F77_REAL *, const F77_REAL&, |
22133
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
65 const F77_REAL&, F77_REAL&, F77_REAL&, F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
66 F77_INT&, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
67 const F77_INT&, F77_INT&, |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30101
diff
changeset
|
68 F77_INT *, F77_REAL *); |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
69 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
70 F77_RET_T |
22133
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
71 F77_FUNC (qagi, QAGI) (quad_float_fcn_ptr, const F77_REAL&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
72 const F77_INT&, const F77_REAL&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
73 const F77_REAL&, F77_REAL&, F77_REAL&, F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
74 F77_INT&, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
75 const F77_INT&, F77_INT&, |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30101
diff
changeset
|
76 F77_INT *, F77_REAL *); |
4552 | 77 } |
3 | 78 |
22846
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
79 static F77_INT |
27109
c3d5afa00588
eliminate obsolete global variable
John W. Eaton <jwe@octave.org>
parents:
27108
diff
changeset
|
80 user_function (const double& x, int&, double& result) |
3 | 81 { |
25681
bef21ac72618
eliminate unnecessary sun-utils.h header file
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
82 result = (*user_fcn) (x); |
260 | 83 |
3136 | 84 return 0; |
3 | 85 } |
86 | |
22846
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
87 static F77_INT |
27109
c3d5afa00588
eliminate obsolete global variable
John W. Eaton <jwe@octave.org>
parents:
27108
diff
changeset
|
88 float_user_function (const float& x, int&, float& result) |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
89 { |
25681
bef21ac72618
eliminate unnecessary sun-utils.h header file
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
90 result = (*float_user_fcn) (x); |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
91 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
92 return 0; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
93 } |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
94 |
3 | 95 double |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
96 DefQuad::do_integrate (octave_idx_type& ier, octave_idx_type& neval, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
97 double& abserr) |
3 | 98 { |
30082
1788b9f6db6a
maint: use "m_" prefix for member variables in file 'Quad.h'.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
99 F77_INT npts = octave::to_f77_int (m_singularities.numel () + 2); |
1788b9f6db6a
maint: use "m_" prefix for member variables in file 'Quad.h'.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
100 double *points = m_singularities.fortran_vec (); |
3 | 101 double result = 0.0; |
1935 | 102 |
22846
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
103 F77_INT leniw = 183*npts - 122; |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
104 Array<F77_INT> iwork (dim_vector (leniw, 1)); |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
105 F77_INT *piwork = iwork.fortran_vec (); |
1935 | 106 |
22846
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
107 F77_INT lenw = 2*leniw - npts; |
11570
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
108 Array<double> work (dim_vector (lenw, 1)); |
1935 | 109 double *pwork = work.fortran_vec (); |
110 | |
30101
6e5e6ce2e705
maint: use "m_" prefix for member variables in class Quad.
Rik <rik@octave.org>
parents:
30082
diff
changeset
|
111 user_fcn = m_f; |
22846
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
112 F77_INT last; |
3 | 113 |
289 | 114 double abs_tol = absolute_tolerance (); |
115 double rel_tol = relative_tolerance (); | |
116 | |
22846
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
117 // NEVAL and IER are output only parameters and F77_INT can not be a |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
118 // wider type than octave_idx_type so we can create local variables |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
119 // here that are the correct type for the Fortran subroutine and then |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
120 // copy them to the function parameters without needing to preserve |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
121 // and pass the values to the Fortran subroutine. |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
122 |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
123 F77_INT xneval, xier; |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
124 |
30082
1788b9f6db6a
maint: use "m_" prefix for member variables in file 'Quad.h'.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
125 F77_XFCN (dqagp, DQAGP, (user_function, m_lower_limit, m_upper_limit, |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
126 npts, points, abs_tol, rel_tol, result, |
22846
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
127 abserr, xneval, xier, leniw, lenw, last, |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
128 piwork, pwork)); |
3 | 129 |
22846
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
130 neval = xneval; |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
131 ier = xier; |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
132 |
3 | 133 return result; |
134 } | |
135 | |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
136 float |
7924 | 137 DefQuad::do_integrate (octave_idx_type&, octave_idx_type&, float&) |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
138 { |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
139 (*current_liboctave_error_handler) ("incorrect integration function called"); |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
140 } |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
141 |
3 | 142 double |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
143 IndefQuad::do_integrate (octave_idx_type& ier, octave_idx_type& neval, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
144 double& abserr) |
3 | 145 { |
146 double result = 0.0; | |
1935 | 147 |
22846
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
148 F77_INT leniw = 128; |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
149 Array<F77_INT> iwork (dim_vector (leniw, 1)); |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
150 F77_INT *piwork = iwork.fortran_vec (); |
1935 | 151 |
22846
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
152 F77_INT lenw = 8*leniw; |
11570
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
153 Array<double> work (dim_vector (lenw, 1)); |
1935 | 154 double *pwork = work.fortran_vec (); |
155 | |
30101
6e5e6ce2e705
maint: use "m_" prefix for member variables in class Quad.
Rik <rik@octave.org>
parents:
30082
diff
changeset
|
156 user_fcn = m_f; |
22846
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
157 F77_INT last; |
3 | 158 |
22846
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
159 F77_INT inf; |
30082
1788b9f6db6a
maint: use "m_" prefix for member variables in file 'Quad.h'.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
160 switch (m_type) |
3 | 161 { |
162 case bound_to_inf: | |
163 inf = 1; | |
164 break; | |
1360 | 165 |
3 | 166 case neg_inf_to_bound: |
167 inf = -1; | |
168 break; | |
1360 | 169 |
3 | 170 case doubly_infinite: |
171 inf = 2; | |
172 break; | |
1360 | 173 |
3 | 174 default: |
175 assert (0); | |
176 break; | |
177 } | |
178 | |
289 | 179 double abs_tol = absolute_tolerance (); |
180 double rel_tol = relative_tolerance (); | |
181 | |
22846
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
182 // NEVAL and IER are output only parameters and F77_INT can not be a |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
183 // wider type than octave_idx_type so we can create local variables |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
184 // here that are the correct type for the Fortran subroutine and then |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
185 // copy them to the function parameters without needing to preserve |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
186 // and pass the values to the Fortran subroutine. |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
187 |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
188 F77_INT xneval, xier; |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
189 |
30082
1788b9f6db6a
maint: use "m_" prefix for member variables in file 'Quad.h'.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
190 F77_XFCN (dqagi, DQAGI, (user_function, m_bound, inf, abs_tol, rel_tol, |
22846
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
191 result, abserr, xneval, xier, leniw, lenw, |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
192 last, piwork, pwork)); |
3 | 193 |
22846
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
194 neval = xneval; |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
195 ier = xier; |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
196 |
3 | 197 return result; |
198 } | |
199 | |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
200 float |
7924 | 201 IndefQuad::do_integrate (octave_idx_type&, octave_idx_type&, float&) |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
202 { |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
203 (*current_liboctave_error_handler) ("incorrect integration function called"); |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
204 } |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
205 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
206 double |
7924 | 207 FloatDefQuad::do_integrate (octave_idx_type&, octave_idx_type&, double&) |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
208 { |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
209 (*current_liboctave_error_handler) ("incorrect integration function called"); |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
210 } |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
211 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
212 float |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
213 FloatDefQuad::do_integrate (octave_idx_type& ier, octave_idx_type& neval, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
214 float& abserr) |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
215 { |
30082
1788b9f6db6a
maint: use "m_" prefix for member variables in file 'Quad.h'.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
216 F77_INT npts = octave::to_f77_int (m_singularities.numel () + 2); |
1788b9f6db6a
maint: use "m_" prefix for member variables in file 'Quad.h'.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
217 float *points = m_singularities.fortran_vec (); |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
218 float result = 0.0; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
219 |
22846
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
220 F77_INT leniw = 183*npts - 122; |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
221 Array<F77_INT> iwork (dim_vector (leniw, 1)); |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
222 F77_INT *piwork = iwork.fortran_vec (); |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
223 |
22846
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
224 F77_INT lenw = 2*leniw - npts; |
11570
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
225 Array<float> work (dim_vector (lenw, 1)); |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
226 float *pwork = work.fortran_vec (); |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
227 |
30101
6e5e6ce2e705
maint: use "m_" prefix for member variables in class Quad.
Rik <rik@octave.org>
parents:
30082
diff
changeset
|
228 float_user_fcn = m_ff; |
22846
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
229 F77_INT last; |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
230 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
231 float abs_tol = single_precision_absolute_tolerance (); |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
232 float rel_tol = single_precision_relative_tolerance (); |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
233 |
22846
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
234 // NEVAL and IER are output only parameters and F77_INT can not be a |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
235 // wider type than octave_idx_type so we can create local variables |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
236 // here that are the correct type for the Fortran subroutine and then |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
237 // copy them to the function parameters without needing to preserve |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
238 // and pass the values to the Fortran subroutine. |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
239 |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
240 F77_INT xneval, xier; |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
241 |
30082
1788b9f6db6a
maint: use "m_" prefix for member variables in file 'Quad.h'.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
242 F77_XFCN (qagp, QAGP, (float_user_function, m_lower_limit, m_upper_limit, |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
243 npts, points, abs_tol, rel_tol, result, |
22846
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
244 abserr, xneval, xier, leniw, lenw, last, |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
245 piwork, pwork)); |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
246 |
22846
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
247 neval = xneval; |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
248 ier = xier; |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
249 |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
250 return result; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
251 } |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
252 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
253 double |
7924 | 254 FloatIndefQuad::do_integrate (octave_idx_type&, octave_idx_type&, double&) |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
255 { |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
256 (*current_liboctave_error_handler) ("incorrect integration function called"); |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
257 } |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
258 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
259 float |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
260 FloatIndefQuad::do_integrate (octave_idx_type& ier, octave_idx_type& neval, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
261 float& abserr) |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
262 { |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
263 float result = 0.0; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
264 |
22846
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
265 F77_INT leniw = 128; |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
266 Array<F77_INT> iwork (dim_vector (leniw, 1)); |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
267 F77_INT *piwork = iwork.fortran_vec (); |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
268 |
22846
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
269 F77_INT lenw = 8*leniw; |
11570
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
270 Array<float> work (dim_vector (lenw, 1)); |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
271 float *pwork = work.fortran_vec (); |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
272 |
30101
6e5e6ce2e705
maint: use "m_" prefix for member variables in class Quad.
Rik <rik@octave.org>
parents:
30082
diff
changeset
|
273 float_user_fcn = m_ff; |
22846
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
274 F77_INT last; |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
275 |
22846
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
276 F77_INT inf; |
30082
1788b9f6db6a
maint: use "m_" prefix for member variables in file 'Quad.h'.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
277 switch (m_type) |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
278 { |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
279 case bound_to_inf: |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
280 inf = 1; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
281 break; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
282 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
283 case neg_inf_to_bound: |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
284 inf = -1; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
285 break; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
286 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
287 case doubly_infinite: |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
288 inf = 2; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
289 break; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
290 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
291 default: |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
292 assert (0); |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
293 break; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
294 } |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
295 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
296 float abs_tol = single_precision_absolute_tolerance (); |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
297 float rel_tol = single_precision_relative_tolerance (); |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
298 |
22846
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
299 // NEVAL and IER are output only parameters and F77_INT can not be a |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
300 // wider type than octave_idx_type so we can create local variables |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
301 // here that are the correct type for the Fortran subroutine and then |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
302 // copy them to the function parameters without needing to preserve |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
303 // and pass the values to the Fortran subroutine. |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
304 |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
305 F77_INT xneval, xier; |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
306 |
30082
1788b9f6db6a
maint: use "m_" prefix for member variables in file 'Quad.h'.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
307 F77_XFCN (qagi, QAGI, (float_user_function, m_bound, inf, abs_tol, rel_tol, |
22846
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
308 result, abserr, xneval, xier, leniw, lenw, |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
309 last, piwork, pwork)); |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
310 |
22846
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
311 neval = xneval; |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
312 ier = xier; |
e827d2c089f4
use F77_INT instead of octave_idx_type for liboctave Quad and lu classes
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
313 |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
314 return result; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
315 } |