00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #if !defined (octave_Quad_h)
00025 #define octave_Quad_h 1
00026
00027 #include <cfloat>
00028
00029 #include "dColVector.h"
00030 #include "fColVector.h"
00031 #include "lo-math.h"
00032
00033 #if !defined (octave_Quad_typedefs)
00034 #define octave_Quad_typedefs 1
00035
00036 typedef double (*integrand_fcn) (double x);
00037 typedef float (*float_integrand_fcn) (float x);
00038
00039 #endif
00040
00041
00042
00043
00044
00045 extern OCTAVE_API int quad_integration_error;
00046
00047 #include "Quad-opts.h"
00048
00049 class
00050 OCTAVE_API
00051 Quad : public Quad_options
00052 {
00053 public:
00054
00055 Quad (integrand_fcn fcn)
00056 : Quad_options (), f (fcn) { }
00057
00058 Quad (float_integrand_fcn fcn)
00059 : Quad_options (), ff (fcn) { }
00060
00061 virtual ~Quad (void) { }
00062
00063 virtual double integrate (void)
00064 {
00065 octave_idx_type ier, neval;
00066 double abserr;
00067 return do_integrate (ier, neval, abserr);
00068 }
00069
00070 virtual float float_integrate (void)
00071 {
00072 octave_idx_type ier, neval;
00073 float abserr;
00074 return do_integrate (ier, neval, abserr);
00075 }
00076
00077 virtual double integrate (octave_idx_type& ier)
00078 {
00079 octave_idx_type neval;
00080 double abserr;
00081 return do_integrate (ier, neval, abserr);
00082 }
00083
00084 virtual float float_integrate (octave_idx_type& ier)
00085 {
00086 octave_idx_type neval;
00087 float abserr;
00088 return do_integrate (ier, neval, abserr);
00089 }
00090
00091 virtual double integrate (octave_idx_type& ier, octave_idx_type& neval)
00092 {
00093 double abserr;
00094 return do_integrate (ier, neval, abserr);
00095 }
00096
00097 virtual float float_integrate (octave_idx_type& ier, octave_idx_type& neval)
00098 {
00099 float abserr;
00100 return do_integrate (ier, neval, abserr);
00101 }
00102
00103 virtual double integrate (octave_idx_type& ier, octave_idx_type& neval, double& abserr)
00104 {
00105 return do_integrate (ier, neval, abserr);
00106 }
00107
00108 virtual float float_integrate (octave_idx_type& ier, octave_idx_type& neval, float& abserr)
00109 {
00110 return do_integrate (ier, neval, abserr);
00111 }
00112
00113 virtual double do_integrate (octave_idx_type& ier, octave_idx_type& neval, double& abserr) = 0;
00114
00115 virtual float do_integrate (octave_idx_type& ier, octave_idx_type& neval, float& abserr) = 0;
00116
00117 protected:
00118
00119 integrand_fcn f;
00120 float_integrand_fcn ff;
00121 };
00122
00123 class
00124 OCTAVE_API
00125 DefQuad : public Quad
00126 {
00127 public:
00128
00129 DefQuad (integrand_fcn fcn)
00130 : Quad (fcn), lower_limit (0.0), upper_limit (1.0), singularities () { }
00131
00132 DefQuad (integrand_fcn fcn, double ll, double ul)
00133 : Quad (fcn), lower_limit (ll), upper_limit (ul), singularities () { }
00134
00135 DefQuad (integrand_fcn fcn, double ll, double ul,
00136 const ColumnVector& sing)
00137 : Quad (fcn), lower_limit (ll), upper_limit (ul),
00138 singularities (sing) { }
00139
00140 DefQuad (integrand_fcn fcn, const ColumnVector& sing)
00141 : Quad (fcn), lower_limit (0.0), upper_limit (1.0),
00142 singularities (sing) { }
00143
00144 ~DefQuad (void) { }
00145
00146 double do_integrate (octave_idx_type& ier, octave_idx_type& neval, double& abserr);
00147
00148 float do_integrate (octave_idx_type& ier, octave_idx_type& neval, float& abserr);
00149
00150 private:
00151
00152 double lower_limit;
00153 double upper_limit;
00154
00155 ColumnVector singularities;
00156 };
00157
00158 class
00159 OCTAVE_API
00160 IndefQuad : public Quad
00161 {
00162 public:
00163
00164 enum IntegralType { bound_to_inf, neg_inf_to_bound, doubly_infinite };
00165
00166 IndefQuad (integrand_fcn fcn)
00167 : Quad (fcn), bound (0.0), type (bound_to_inf) { }
00168
00169 IndefQuad (integrand_fcn fcn, double b, IntegralType t)
00170 : Quad (fcn), bound (b), type (t) { }
00171
00172 ~IndefQuad (void) { }
00173
00174 double do_integrate (octave_idx_type& ier, octave_idx_type& neval, double& abserr);
00175
00176 float do_integrate (octave_idx_type& ier, octave_idx_type& neval, float& abserr);
00177
00178 private:
00179
00180 double bound;
00181 IntegralType type;
00182 int integration_error;
00183 };
00184
00185 class
00186 OCTAVE_API
00187 FloatDefQuad : public Quad
00188 {
00189 public:
00190
00191 FloatDefQuad (float_integrand_fcn fcn)
00192 : Quad (fcn), lower_limit (0.0), upper_limit (1.0), singularities () { }
00193
00194 FloatDefQuad (float_integrand_fcn fcn, float ll, float ul)
00195 : Quad (fcn), lower_limit (ll), upper_limit (ul), singularities () { }
00196
00197 FloatDefQuad (float_integrand_fcn fcn, float ll, float ul,
00198 const FloatColumnVector& sing)
00199 : Quad (fcn), lower_limit (ll), upper_limit (ul),
00200 singularities (sing) { }
00201
00202 FloatDefQuad (float_integrand_fcn fcn, const FloatColumnVector& sing)
00203 : Quad (fcn), lower_limit (0.0), upper_limit (1.0),
00204 singularities (sing) { }
00205
00206 ~FloatDefQuad (void) { }
00207
00208 double do_integrate (octave_idx_type& ier, octave_idx_type& neval, double& abserr);
00209
00210 float do_integrate (octave_idx_type& ier, octave_idx_type& neval, float& abserr);
00211
00212 private:
00213
00214 float lower_limit;
00215 float upper_limit;
00216
00217 FloatColumnVector singularities;
00218 };
00219
00220 class
00221 OCTAVE_API
00222 FloatIndefQuad : public Quad
00223 {
00224 public:
00225
00226 enum IntegralType { bound_to_inf, neg_inf_to_bound, doubly_infinite };
00227
00228 FloatIndefQuad (float_integrand_fcn fcn)
00229 : Quad (fcn), bound (0.0), type (bound_to_inf) { }
00230
00231 FloatIndefQuad (float_integrand_fcn fcn, double b, IntegralType t)
00232 : Quad (fcn), bound (b), type (t) { }
00233
00234 ~FloatIndefQuad (void) { }
00235
00236 double do_integrate (octave_idx_type& ier, octave_idx_type& neval, double& abserr);
00237
00238 float do_integrate (octave_idx_type& ier, octave_idx_type& neval, float& abserr);
00239
00240 private:
00241
00242 float bound;
00243 IntegralType type;
00244 int integration_error;
00245 };
00246
00247 #endif
00248
00249
00250
00251
00252
00253