All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
NumericalDefiniteIntegral.h
Go to the documentation of this file.
1 // $Id: NumericalDefiniteIntegral.h,v 1.3 2008/10/27 19:22:20 marcocle Exp $
2 // ============================================================================
3 #ifndef GAUDIMATH_NUMERICALDEFINITEINTEGRAL_H
4 #define GAUDIMATH_NUMERICALDEFINITEINTEGRAL_H 1
5 // ============================================================================
6 // Include files
7 // ============================================================================
8 // STD & STL
9 // ============================================================================
10 #include <string>
11 // ============================================================================
12 // GaudiKernel
13 // ============================================================================
14 #include "GaudiKernel/StatusCode.h"
15 // ============================================================================
16 // GaudiMath
17 // ============================================================================
18 #include "GaudiMath/Integration.h"
19 // ============================================================================
20 // CLHEP
21 // ============================================================================
22 #include "CLHEP/GenericFunctions/AbsFunction.hh"
23 // ============================================================================
24 
25 namespace Genfun
26 {
27  namespace GaudiMathImplementation
28  {
72  class GAUDI_API NumericalDefiniteIntegral : public AbsFunction
73  {
74  public:
75  struct _Workspace ;
76  struct _Function ;
77  public:
78 
80  typedef std::vector<double> Points ;
81 
82  public:
83 
85  FUNCTION_OBJECT_DEF( NumericalDefiniteIntegral )
86 
87  public:
88 
141  ( const AbsFunction& function ,
142  const size_t index ,
143  const double a ,
144  const double b ,
145  const GaudiMath::Integration::Type type =
146  GaudiMath::Integration::Adaptive ,
147  const GaudiMath::Integration::KronrodRule rule =
148  GaudiMath::Integration::Default ,
149  const double epsabs = 1.e-10 ,
150  const double epsrel = 1.e-7 ,
151  const size_t size = 1000 );
152 
153 
183  ( const AbsFunction& function ,
184  const size_t index ,
185  const double a ,
186  const double b ,
187  const Points& points ,
188  const double epsabs = 1e-9 ,
189  const double epsrel = 1.e-6 ,
190  const size_t size = 1000 ) ;
191 
192 
219  ( const AbsFunction& function ,
220  const size_t index ,
221  const double a ,
222  const GaudiMath::Integration::Inf b =
223  GaudiMath::Integration::Infinity ,
224  const double epsabs = 1e-9 ,
225  const double epsrel = 1.e-6 ,
226  const size_t size = 1000 ) ;
227 
254  ( const AbsFunction& function ,
255  const size_t index ,
256  const GaudiMath::Integration::Inf a ,
257  const double b ,
258  const double epsabs = 1e-9 ,
259  const double epsrel = 1.e-6 ,
260  const size_t size = 1000 ) ;
261 
286  ( const AbsFunction& function ,
287  const size_t index ,
288  // FIXME: The next two arguments should be "double" but are "float" to resolve the
289  // ambiguity with the first constructor when providing
290  // '(const Genfun::AbsFunction, const unsigned int, const double, const double)'
291  const float epsabs = 1e-9 ,
292  const float epsrel = 1.e-6 ,
293  const size_t size = 1000 ) ;
294 
297 
299  virtual ~NumericalDefiniteIntegral() ;
300 
301  public:
302 
304  virtual unsigned int dimensionality() const { return m_DIM ; }
305 
307  virtual double operator() ( double argument ) const ;
309  virtual double operator() ( const Argument& argument ) const ;
310 
312  virtual bool hasAnalyticDerivative() const { return true ;}
313 
315  virtual Genfun::Derivative partial ( unsigned int index ) const;
316 
317  public:
318 
320  const AbsFunction& function () const { return *m_function ; }
322  double a () const { return m_a ; }
323  double b () const { return m_b ; }
325  const Points& points () const { return m_points ; }
327  double epsabs () const { return m_epsabs ; }
329  double epsrel () const { return m_epsrel ; }
330 
332  double result () const { return m_result ; }
334  double error () const { return m_error ; }
335 
336  // maximal number of bisection integvals for adaptive algorithms
337  size_t size () const { return m_size ; }
338 
341  type () const { return m_type ; }
344  category () const { return m_category ; }
347  rule () const { return m_rule ; }
348 
349  protected:
350 
351  // adaptive integration on infinite intervals
352  double QAGI ( _Function* fun ) const ;
353  // adaptive integration with known singular points
354  double QAGP ( _Function* fun ) const ;
355  // non-adaptive integration
356  double QNG ( _Function* fun ) const ;
357  // adaptive integration
358  double QAG ( _Function* fun ) const ;
359  // adaptive integral with singularities
360  double QAGS ( _Function* fun ) const ;
361 
362  // allocate the integration workspace
363  _Workspace* allocate () const ;
364  // the integration workspace
365  _Workspace* ws () const
366  { return m_ws ; };
367 
368  // throw the exception
369  StatusCode Exception
370  ( const std::string& message ,
371  const StatusCode& sc = StatusCode::FAILURE ) const ;
372 
373  private:
374 
375  // defautl constructor is disabled
377  // assignement is disabled
379 
380  private:
381 
382  const AbsFunction* m_function ;
383  size_t m_DIM ;
384  size_t m_index ;
385 
386  double m_a ;
387  double m_b ;
388  bool m_ia ;
389  bool m_ib ;
390 
394 
396  double* m_pdata ;
397 
398  double m_epsabs ;
399  double m_epsrel ;
400 
401  mutable double m_result ;
402  mutable double m_error ;
403 
404  size_t m_size ;
405  mutable _Workspace* m_ws ;
406 
407  mutable Argument m_argument ;
408  mutable Argument m_argF ;
409 
410  };
411 
412  } // end of namespace GaudiMathImplementation
413 } // end of namespace Genfun
414 
415 // ============================================================================
416 // The END
417 // ============================================================================
418 #endif // GAUDIMATH_NUMERICALDEFINITEINTEGRAL_H
419 // ============================================================================
virtual bool hasAnalyticDerivative() const
Does this function have an analytic derivative?
GaudiMath::Integration::Category category() const
integration category
Category
integration category
Definition: Integration.h:32
Genfun::GaudiMathImplementation::NumericalDerivative Derivative
Definition: GaudiMath.h:31
string type
Definition: gaudirun.py:126
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
Type
type of integration (for finite limits)
Definition: Integration.h:27
GaudiMath::Integration::Type type() const
integration type
std::vector< double > Points
typedef for vector of singular points
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:27
KronrodRule
integration rule
Definition: Integration.h:36
#define GAUDI_API
Definition: Kernel.h:108
Type
the list of available types for ntuples
Definition: TupleObj.h:63
GaudiMath::Integration::KronrodRule rule() const
integration rule
collection of common types for classes NumericalIndefiniteIntegral and NumericalDefiniteIntegral ...
This class allows the numerical evaluation of the following functions: