GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
Quad.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1993-2025 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if ! defined (octave_Quad_h)
27#define octave_Quad_h 1
28
29#include "octave-config.h"
30
31#include "dColVector.h"
32#include "fColVector.h"
33
34typedef double (*integrand_fcn) (double x);
35typedef float (*float_integrand_fcn) (float x);
36
37#include "Quad-opts.h"
38
40{
41public:
42
43 Quad () = delete;
44
46 : Quad_options (), m_f (fcn), m_ff () { }
47
49 : Quad_options (), m_f (), m_ff (fcn) { }
50
51 OCTAVE_DEFAULT_COPY_MOVE (Quad)
52
53 virtual ~Quad () = default;
54
55 virtual double integrate ()
56 {
57 octave_idx_type ier, neval;
58 double abserr;
59 return do_integrate (ier, neval, abserr);
60 }
61
62 virtual float float_integrate ()
63 {
64 octave_idx_type ier, neval;
65 float abserr;
66 return do_integrate (ier, neval, abserr);
67 }
68
69 virtual double integrate (octave_idx_type& ier)
70 {
71 octave_idx_type neval;
72 double abserr;
73 return do_integrate (ier, neval, abserr);
74 }
75
76 virtual float float_integrate (octave_idx_type& ier)
77 {
78 octave_idx_type neval;
79 float abserr;
80 return do_integrate (ier, neval, abserr);
81 }
82
83 virtual double integrate (octave_idx_type& ier, octave_idx_type& neval)
84 {
85 double abserr;
86 return do_integrate (ier, neval, abserr);
87 }
88
89 virtual float float_integrate (octave_idx_type& ier, octave_idx_type& neval)
90 {
91 float abserr;
92 return do_integrate (ier, neval, abserr);
93 }
94
95 virtual double integrate (octave_idx_type& ier, octave_idx_type& neval,
96 double& abserr)
97 {
98 return do_integrate (ier, neval, abserr);
99 }
100
102 float& abserr)
103 {
104 return do_integrate (ier, neval, abserr);
105 }
106
107 virtual double do_integrate (octave_idx_type& ier, octave_idx_type& neval,
108 double& abserr) = 0;
109
110 virtual float do_integrate (octave_idx_type& ier, octave_idx_type& neval,
111 float& abserr) = 0;
112
113protected:
114
117};
118
119class OCTAVE_API DefQuad : public Quad
120{
121public:
122
123 DefQuad () = delete;
124
126 : Quad (fcn), m_lower_limit (0.0), m_upper_limit (1.0), m_singularities ()
127 { }
128
129 DefQuad (integrand_fcn fcn, double ll, double ul)
130 : Quad (fcn), m_lower_limit (ll), m_upper_limit (ul), m_singularities ()
131 { }
132
133 DefQuad (integrand_fcn fcn, double ll, double ul,
134 const ColumnVector& sing)
135 : Quad (fcn), m_lower_limit (ll), m_upper_limit (ul),
136 m_singularities (sing) { }
137
139 : Quad (fcn), m_lower_limit (0.0), m_upper_limit (1.0),
140 m_singularities (sing) { }
141
142 OCTAVE_DEFAULT_COPY_MOVE_DELETE (DefQuad)
143
144 double do_integrate (octave_idx_type& ier, octave_idx_type& neval,
145 double& abserr);
146
147 OCTAVE_NORETURN float do_integrate (octave_idx_type& ier,
148 octave_idx_type& neval, float& abserr);
149
150private:
151
152 double m_lower_limit;
153 double m_upper_limit;
154
155 ColumnVector m_singularities;
156};
157
159{
160public:
161
162 enum IntegralType { bound_to_inf, neg_inf_to_bound, doubly_infinite };
163
164 IndefQuad () = delete;
165
167 : Quad (fcn), m_bound (0.0), m_type (bound_to_inf) { }
168
170 : Quad (fcn), m_bound (b), m_type (t) { }
171
172 OCTAVE_DEFAULT_COPY_MOVE_DELETE (IndefQuad)
173
174 double do_integrate (octave_idx_type& ier, octave_idx_type& neval,
175 double& abserr);
176
177 OCTAVE_NORETURN float do_integrate (octave_idx_type& ier,
178 octave_idx_type& neval, float& abserr);
179
180private:
181
182 double m_bound;
183 IntegralType m_type;
184};
185
187{
188public:
189
190 FloatDefQuad () = delete;
191
193 : Quad (fcn), m_lower_limit (0.0), m_upper_limit (1.0), m_singularities ()
194 { }
195
196 FloatDefQuad (float_integrand_fcn fcn, float ll, float ul)
197 : Quad (fcn), m_lower_limit (ll), m_upper_limit (ul), m_singularities ()
198 { }
199
200 FloatDefQuad (float_integrand_fcn fcn, float ll, float ul,
201 const FloatColumnVector& sing)
202 : Quad (fcn), m_lower_limit (ll), m_upper_limit (ul),
203 m_singularities (sing) { }
204
206 : Quad (fcn), m_lower_limit (0.0), m_upper_limit (1.0),
207 m_singularities (sing) { }
208
209 OCTAVE_DEFAULT_COPY_MOVE_DELETE (FloatDefQuad)
210
211 OCTAVE_NORETURN double do_integrate (octave_idx_type& ier,
212 octave_idx_type& neval, double& abserr);
213
214 float do_integrate (octave_idx_type& ier, octave_idx_type& neval,
215 float& abserr);
216
217private:
218
219 float m_lower_limit;
220 float m_upper_limit;
221
222 FloatColumnVector m_singularities;
223};
224
226{
227public:
228
229 enum IntegralType { bound_to_inf, neg_inf_to_bound, doubly_infinite };
230
231 FloatIndefQuad () = delete;
232
234 : Quad (fcn), m_bound (0.0), m_type (bound_to_inf) { }
235
237 : Quad (fcn), m_bound (b), m_type (t) { }
238
239 OCTAVE_DEFAULT_COPY_MOVE_DELETE (FloatIndefQuad)
240
241 OCTAVE_NORETURN double do_integrate (octave_idx_type& ier,
242 octave_idx_type& neval, double& abserr);
243
244 float do_integrate (octave_idx_type& ier, octave_idx_type& neval,
245 float& abserr);
246
247private:
248
249 float m_bound;
250 IntegralType m_type;
251};
252
253#endif
double(* integrand_fcn)(double x)
Definition Quad.h:34
float(* float_integrand_fcn)(float x)
Definition Quad.h:35
DefQuad(integrand_fcn fcn)
Definition Quad.h:125
DefQuad(integrand_fcn fcn, const ColumnVector &sing)
Definition Quad.h:138
DefQuad()=delete
DefQuad(integrand_fcn fcn, double ll, double ul, const ColumnVector &sing)
Definition Quad.h:133
DefQuad(integrand_fcn fcn, double ll, double ul)
Definition Quad.h:129
FloatDefQuad(float_integrand_fcn fcn)
Definition Quad.h:192
FloatDefQuad()=delete
FloatDefQuad(float_integrand_fcn fcn, const FloatColumnVector &sing)
Definition Quad.h:205
FloatDefQuad(float_integrand_fcn fcn, float ll, float ul, const FloatColumnVector &sing)
Definition Quad.h:200
FloatDefQuad(float_integrand_fcn fcn, float ll, float ul)
Definition Quad.h:196
FloatIndefQuad(float_integrand_fcn fcn, double b, IntegralType t)
Definition Quad.h:236
FloatIndefQuad(float_integrand_fcn fcn)
Definition Quad.h:233
FloatIndefQuad()=delete
IndefQuad()=delete
IndefQuad(integrand_fcn fcn, double b, IntegralType t)
Definition Quad.h:169
IndefQuad(integrand_fcn fcn)
Definition Quad.h:166
IntegralType
Definition Quad.h:162
@ bound_to_inf
Definition Quad.h:162
Definition Quad.h:40
virtual double integrate(octave_idx_type &ier, octave_idx_type &neval)
Definition Quad.h:83
virtual float do_integrate(octave_idx_type &ier, octave_idx_type &neval, float &abserr)=0
float_integrand_fcn m_ff
Definition Quad.h:116
virtual double integrate(octave_idx_type &ier, octave_idx_type &neval, double &abserr)
Definition Quad.h:95
virtual double do_integrate(octave_idx_type &ier, octave_idx_type &neval, double &abserr)=0
Quad(float_integrand_fcn fcn)
Definition Quad.h:48
virtual double integrate(octave_idx_type &ier)
Definition Quad.h:69
Quad()=delete
integrand_fcn m_f
Definition Quad.h:115
virtual float float_integrate()
Definition Quad.h:62
virtual float float_integrate(octave_idx_type &ier)
Definition Quad.h:76
virtual float float_integrate(octave_idx_type &ier, octave_idx_type &neval)
Definition Quad.h:89
Quad(integrand_fcn fcn)
Definition Quad.h:45
virtual float float_integrate(octave_idx_type &ier, octave_idx_type &neval, float &abserr)
Definition Quad.h:101
F77_RET_T const F77_DBLE * x
#define OCTAVE_API
Definition main.in.cc:55