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