3
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
3
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
1315
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
3
|
20 |
|
21 */ |
|
22 |
382
|
23 #if !defined (octave_Quad_h) |
|
24 #define octave_Quad_h 1 |
|
25 |
1296
|
26 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
3
|
29 |
1536
|
30 #include <cfloat> |
|
31 #include <cmath> |
|
32 |
1296
|
33 #include "dColVector.h" |
3
|
34 |
384
|
35 #if !defined (octave_Quad_typedefs) |
|
36 #define octave_Quad_typedefs 1 |
3
|
37 |
|
38 typedef double (*integrand_fcn) (double x); |
|
39 |
|
40 #endif |
|
41 |
260
|
42 // XXX FIXME XXX -- would be nice to not have to have this global |
|
43 // variable. |
|
44 // Nonzero means an error occurred in the calculation of the integrand |
|
45 // function, and the user wants us to quit. |
|
46 extern int quad_integration_error; |
|
47 |
3998
|
48 #include "Quad-opts.h" |
289
|
49 |
1859
|
50 class |
|
51 Quad : public Quad_options |
3
|
52 { |
|
53 public: |
|
54 |
1859
|
55 Quad (integrand_fcn fcn) |
|
56 : Quad_options (), f (fcn) { } |
|
57 |
2425
|
58 virtual ~Quad (void) { } |
2424
|
59 |
1528
|
60 virtual double integrate (void) |
|
61 { |
|
62 int ier, neval; |
|
63 double abserr; |
3511
|
64 return do_integrate (ier, neval, abserr); |
1528
|
65 } |
3
|
66 |
1528
|
67 virtual double integrate (int& ier) |
|
68 { |
|
69 int neval; |
|
70 double abserr; |
3511
|
71 return do_integrate (ier, neval, abserr); |
1528
|
72 } |
|
73 |
|
74 virtual double integrate (int& ier, int& neval) |
|
75 { |
|
76 double abserr; |
3511
|
77 return do_integrate (ier, neval, abserr); |
1528
|
78 } |
|
79 |
3511
|
80 virtual double integrate (int& ier, int& neval, double& abserr) |
|
81 { |
|
82 return do_integrate (ier, neval, abserr); |
|
83 } |
|
84 |
|
85 virtual double do_integrate (int& ier, int& neval, double& abserr) = 0; |
3
|
86 |
|
87 protected: |
|
88 |
|
89 integrand_fcn f; |
|
90 }; |
|
91 |
1859
|
92 class |
|
93 DefQuad : public Quad |
3
|
94 { |
|
95 public: |
|
96 |
1859
|
97 DefQuad (integrand_fcn fcn) |
|
98 : Quad (fcn), lower_limit (0.0), upper_limit (1.0), singularities () { } |
1528
|
99 |
1859
|
100 DefQuad (integrand_fcn fcn, double ll, double ul) |
|
101 : Quad (fcn), lower_limit (ll), upper_limit (ul), singularities () { } |
1528
|
102 |
|
103 DefQuad (integrand_fcn fcn, double ll, double ul, |
1859
|
104 const ColumnVector& sing) |
|
105 : Quad (fcn), lower_limit (ll), upper_limit (ul), |
|
106 singularities (sing) { } |
1528
|
107 |
1859
|
108 DefQuad (integrand_fcn fcn, const ColumnVector& sing) |
|
109 : Quad (fcn), lower_limit (0.0), upper_limit (1.0), |
|
110 singularities (sing) { } |
1528
|
111 |
2424
|
112 ~DefQuad (void) { } |
|
113 |
3511
|
114 double do_integrate (int& ier, int& neval, double& abserr); |
3
|
115 |
|
116 private: |
|
117 |
|
118 double lower_limit; |
|
119 double upper_limit; |
|
120 |
1528
|
121 ColumnVector singularities; |
3
|
122 }; |
|
123 |
1859
|
124 class |
|
125 IndefQuad : public Quad |
3
|
126 { |
|
127 public: |
|
128 |
|
129 enum IntegralType { bound_to_inf, neg_inf_to_bound, doubly_infinite }; |
|
130 |
1859
|
131 IndefQuad (integrand_fcn fcn) |
|
132 : Quad (fcn), bound (0.0), type (bound_to_inf) { } |
1528
|
133 |
1859
|
134 IndefQuad (integrand_fcn fcn, double b, IntegralType t) |
|
135 : Quad (fcn), bound (b), type (t) { } |
1528
|
136 |
2424
|
137 ~IndefQuad (void) { } |
|
138 |
3511
|
139 double do_integrate (int& ier, int& neval, double& abserr); |
3
|
140 |
|
141 private: |
|
142 |
|
143 double bound; |
|
144 IntegralType type; |
1859
|
145 int integration_error; |
3
|
146 }; |
|
147 |
|
148 #endif |
|
149 |
|
150 /* |
|
151 ;;; Local Variables: *** |
|
152 ;;; mode: C++ *** |
|
153 ;;; End: *** |
|
154 */ |