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