![]() |
|
|
Generated: 8 Jan 2009 |
00001 // $Id: NumericalDefiniteIntegral.h,v 1.3 2008/10/27 19:22:20 marcocle Exp $ 00002 // ============================================================================ 00003 #ifndef GAUDIMATH_NUMERICALDEFINITEINTEGRAL_H 00004 #define GAUDIMATH_NUMERICALDEFINITEINTEGRAL_H 1 00005 // ============================================================================ 00006 // Include files 00007 // ============================================================================ 00008 // STD & STL 00009 // ============================================================================ 00010 #include <string> 00011 // ============================================================================ 00012 // GaudiKernel 00013 // ============================================================================ 00014 #include "GaudiKernel/StatusCode.h" 00015 // ============================================================================ 00016 // GaudiMath 00017 // ============================================================================ 00018 #include "GaudiMath/Integration.h" 00019 // ============================================================================ 00020 // CLHEP 00021 // ============================================================================ 00022 #include "CLHEP/GenericFunctions/AbsFunction.hh" 00023 // ============================================================================ 00024 00025 namespace Genfun 00026 { 00027 namespace GaudiMathImplementation 00028 { 00072 class NumericalDefiniteIntegral : public AbsFunction 00073 { 00074 public: 00075 struct _Workspace ; 00076 struct _Function ; 00077 public: 00078 00080 typedef std::vector<double> Points ; 00081 00082 public: 00083 00085 FUNCTION_OBJECT_DEF( NumericalDefiniteIntegral ) ; 00086 00087 public: 00088 00140 NumericalDefiniteIntegral 00141 ( const AbsFunction& function , 00142 const size_t index , 00143 const double a , 00144 const double b , 00145 const GaudiMath::Integration::Type type = 00146 GaudiMath::Integration::Adaptive , 00147 const GaudiMath::Integration::KronrodRule rule = 00148 GaudiMath::Integration::Default , 00149 const double epsabs = 1.e-10 , 00150 const double epsrel = 1.e-7 , 00151 const size_t size = 1000 ); 00152 00153 00182 NumericalDefiniteIntegral 00183 ( const AbsFunction& function , 00184 const size_t index , 00185 const double a , 00186 const double b , 00187 const Points& points , 00188 const double epsabs = 1e-9 , 00189 const double epsrel = 1.e-6 , 00190 const size_t size = 1000 ) ; 00191 00192 00218 NumericalDefiniteIntegral 00219 ( const AbsFunction& function , 00220 const size_t index , 00221 const double a , 00222 const GaudiMath::Integration::Inf b = 00223 GaudiMath::Integration::Infinity , 00224 const double epsabs = 1e-9 , 00225 const double epsrel = 1.e-6 , 00226 const size_t size = 1000 ) ; 00227 00253 NumericalDefiniteIntegral 00254 ( const AbsFunction& function , 00255 const size_t index , 00256 const GaudiMath::Integration::Inf a , 00257 const double b , 00258 const double epsabs = 1e-9 , 00259 const double epsrel = 1.e-6 , 00260 const size_t size = 1000 ) ; 00261 00285 NumericalDefiniteIntegral 00286 ( const AbsFunction& function , 00287 const size_t index , 00288 // FIXME: The next two arguments should be "double" but are "float" to resolve the 00289 // ambiguity with the first constructor when providing 00290 // '(const Genfun::AbsFunction, const unsigned int, const double, const double)' 00291 const float epsabs = 1e-9 , 00292 const float epsrel = 1.e-6 , 00293 const size_t size = 1000 ) ; 00294 00296 NumericalDefiniteIntegral ( const NumericalDefiniteIntegral& ) ; 00297 00299 virtual ~NumericalDefiniteIntegral() ; 00300 00301 public: 00302 00304 virtual unsigned int dimensionality() const { return m_DIM ; } 00305 00307 virtual double operator() ( double argument ) const ; 00309 virtual double operator() ( const Argument& argument ) const ; 00310 00312 virtual bool hasAnalyticDerivative() const { return true ;} 00313 00315 virtual Genfun::Derivative partial ( unsigned int index ) const; 00316 00317 public: 00318 00320 const AbsFunction& function () const { return *m_function ; } 00322 double a () const { return m_a ; } 00323 double b () const { return m_b ; } 00325 const Points& points () const { return m_points ; } 00327 double epsabs () const { return m_epsabs ; } 00329 double epsrel () const { return m_epsrel ; } 00330 00332 double result () const { return m_result ; } 00334 double error () const { return m_error ; } 00335 00336 // maximal number of bisection integvals for adaptive algorithms 00337 size_t size () const { return m_size ; } 00338 00340 GaudiMath::Integration::Type 00341 type () const { return m_type ; } 00343 GaudiMath::Integration::Category 00344 category () const { return m_category ; } 00346 GaudiMath::Integration::KronrodRule 00347 rule () const { return m_rule ; } 00348 00349 protected: 00350 00351 // adaptive integration on infinite intervals 00352 double QAGI ( _Function* fun ) const ; 00353 // adaptive integration with known singular points 00354 double QAGP ( _Function* fun ) const ; 00355 // non-adaptive integration 00356 double QNG ( _Function* fun ) const ; 00357 // adaptive integration 00358 double QAG ( _Function* fun ) const ; 00359 // adaptive integral with singularities 00360 double QAGS ( _Function* fun ) const ; 00361 00362 // allocate the integration workspace 00363 _Workspace* allocate () const ; 00364 // the integration workspace 00365 _Workspace* ws () const 00366 { return m_ws ; }; 00367 00368 // throw the exception 00369 StatusCode Exception 00370 ( const std::string& message , 00371 const StatusCode& sc = StatusCode::FAILURE ) const ; 00372 00373 private: 00374 00375 // defautl constructor is disabled 00376 NumericalDefiniteIntegral(); 00377 // assignement is disabled 00378 NumericalDefiniteIntegral& operator=( const NumericalDefiniteIntegral& ); 00379 00380 private: 00381 00382 const AbsFunction* m_function ; 00383 size_t m_DIM ; 00384 size_t m_index ; 00385 00386 double m_a ; 00387 double m_b ; 00388 bool m_ia ; 00389 bool m_ib ; 00390 00391 GaudiMath::Integration::Type m_type ; 00392 GaudiMath::Integration::Category m_category ; 00393 GaudiMath::Integration::KronrodRule m_rule ; 00394 00395 Points m_points ; 00396 double* m_pdata ; 00397 00398 double m_epsabs ; 00399 double m_epsrel ; 00400 00401 mutable double m_result ; 00402 mutable double m_error ; 00403 00404 size_t m_size ; 00405 mutable _Workspace* m_ws ; 00406 00407 mutable Argument m_argument ; 00408 mutable Argument m_argF ; 00409 00410 }; 00411 00412 }; // end of namespace GaudiMathImplementation 00413 }; // end of namespace Genfun 00414 00415 // ============================================================================ 00416 // The END 00417 // ============================================================================ 00418 #endif // GAUDIMATH_NUMERICALDEFINITEINTEGRAL_H 00419 // ============================================================================