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 |
|
40 class Quad |
|
41 { |
|
42 public: |
|
43 |
|
44 Quad (integrand_fcn fcn); |
|
45 Quad (integrand_fcn fcn, double abs, double rel); |
|
46 |
|
47 virtual double integrate (void); |
|
48 virtual double integrate (int& ier); |
|
49 virtual double integrate (int& ier, int& neval); |
|
50 virtual double integrate (int& ier, int& neval, double& abserr) = 0; |
|
51 |
|
52 protected: |
|
53 |
|
54 double absolute_tolerance; |
|
55 double relative_tolerance; |
|
56 |
|
57 integrand_fcn f; |
|
58 }; |
|
59 |
|
60 class DefQuad : public Quad |
|
61 { |
|
62 public: |
|
63 |
|
64 DefQuad (integrand_fcn fcn); |
|
65 DefQuad (integrand_fcn fcn, double ll, double ul); |
|
66 DefQuad (integrand_fcn fcn, double ll, double ul, double abs, double rel); |
|
67 DefQuad (integrand_fcn fcn, double ll, double ul, const Vector& sing); |
|
68 DefQuad (integrand_fcn fcn, const Vector& sing, double abs, double rel); |
|
69 DefQuad (integrand_fcn fcn, const Vector& sing); |
|
70 DefQuad (integrand_fcn fcn, double ll, double ul, const Vector& sing, |
|
71 double abs, double rel); |
|
72 |
|
73 double integrate (int& ier, int& neval, double& abserr); |
|
74 |
|
75 private: |
|
76 |
|
77 double lower_limit; |
|
78 double upper_limit; |
|
79 |
|
80 Vector singularities; |
|
81 }; |
|
82 |
|
83 class IndefQuad : public Quad |
|
84 { |
|
85 public: |
|
86 |
|
87 enum IntegralType { bound_to_inf, neg_inf_to_bound, doubly_infinite }; |
|
88 |
|
89 IndefQuad (integrand_fcn fcn); |
|
90 IndefQuad (integrand_fcn fcn, double b, IntegralType t); |
|
91 IndefQuad (integrand_fcn fcn, double b, IntegralType t, double abs, |
|
92 double rel); |
|
93 IndefQuad (integrand_fcn fcn, double abs, double rel); |
|
94 |
|
95 double integrate (int& ier, int& neval, double& abserr); |
|
96 |
|
97 private: |
|
98 |
|
99 double bound; |
|
100 IntegralType type; |
|
101 }; |
|
102 |
|
103 #endif |
|
104 |
|
105 /* |
|
106 ;;; Local Variables: *** |
|
107 ;;; mode: C++ *** |
|
108 ;;; page-delimiter: "^/\\*" *** |
|
109 ;;; End: *** |
|
110 */ |