3
|
1 // Quad.h -*- C++ -*- |
|
2 /* |
|
3 |
296
|
4 Copyright (C) 1992, 1993, 1994 John W. Eaton |
3
|
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 |
382
|
24 #if !defined (octave_Quad_h) |
|
25 #define octave_Quad_h 1 |
|
26 |
|
27 extern "C++" { |
3
|
28 |
|
29 #include "Matrix.h" |
|
30 |
|
31 #ifndef Vector |
|
32 #define Vector ColumnVector |
|
33 #endif |
|
34 |
|
35 #ifndef _Quad_typedefs |
|
36 #define _Quad_typedefs 1 |
|
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 |
289
|
48 class Quad_options |
|
49 { |
|
50 public: |
|
51 |
|
52 Quad_options (void); |
|
53 Quad_options (const Quad_options& opt); |
|
54 |
|
55 Quad_options& operator = (const Quad_options& opt); |
|
56 |
|
57 ~Quad_options (void); |
|
58 |
|
59 void init (void); |
|
60 void copy (const Quad_options& opt); |
|
61 |
|
62 void set_default_options (void); |
|
63 |
|
64 void set_absolute_tolerance (double); |
|
65 void set_relative_tolerance (double); |
|
66 |
|
67 double absolute_tolerance (void); |
|
68 double relative_tolerance (void); |
|
69 |
|
70 private: |
|
71 |
|
72 double x_absolute_tolerance; |
|
73 double x_relative_tolerance; |
|
74 }; |
|
75 |
|
76 class Quad : public Quad_options |
3
|
77 { |
|
78 public: |
|
79 |
|
80 Quad (integrand_fcn fcn); |
|
81 Quad (integrand_fcn fcn, double abs, double rel); |
|
82 |
|
83 virtual double integrate (void); |
|
84 virtual double integrate (int& ier); |
|
85 virtual double integrate (int& ier, int& neval); |
|
86 virtual double integrate (int& ier, int& neval, double& abserr) = 0; |
|
87 |
|
88 protected: |
|
89 |
|
90 integrand_fcn f; |
|
91 }; |
|
92 |
|
93 class DefQuad : public Quad |
|
94 { |
|
95 public: |
|
96 |
|
97 DefQuad (integrand_fcn fcn); |
|
98 DefQuad (integrand_fcn fcn, double ll, double ul); |
|
99 DefQuad (integrand_fcn fcn, double ll, double ul, double abs, double rel); |
|
100 DefQuad (integrand_fcn fcn, double ll, double ul, const Vector& sing); |
|
101 DefQuad (integrand_fcn fcn, const Vector& sing, double abs, double rel); |
|
102 DefQuad (integrand_fcn fcn, const Vector& sing); |
|
103 DefQuad (integrand_fcn fcn, double ll, double ul, const Vector& sing, |
|
104 double abs, double rel); |
|
105 |
|
106 double integrate (int& ier, int& neval, double& abserr); |
|
107 |
|
108 private: |
|
109 |
|
110 double lower_limit; |
|
111 double upper_limit; |
|
112 |
|
113 Vector singularities; |
|
114 }; |
|
115 |
|
116 class IndefQuad : public Quad |
|
117 { |
|
118 public: |
|
119 |
|
120 enum IntegralType { bound_to_inf, neg_inf_to_bound, doubly_infinite }; |
|
121 |
|
122 IndefQuad (integrand_fcn fcn); |
|
123 IndefQuad (integrand_fcn fcn, double b, IntegralType t); |
|
124 IndefQuad (integrand_fcn fcn, double b, IntegralType t, double abs, |
|
125 double rel); |
|
126 IndefQuad (integrand_fcn fcn, double abs, double rel); |
|
127 |
|
128 double integrate (int& ier, int& neval, double& abserr); |
|
129 |
|
130 private: |
|
131 |
260
|
132 int integration_error; |
3
|
133 double bound; |
|
134 IntegralType type; |
|
135 }; |
|
136 |
382
|
137 } // extern "C++" |
|
138 |
3
|
139 #endif |
|
140 |
|
141 /* |
|
142 ;;; Local Variables: *** |
|
143 ;;; mode: C++ *** |
|
144 ;;; page-delimiter: "^/\\*" *** |
|
145 ;;; End: *** |
|
146 */ |