NumericalIndefiniteIntegral.h
Go to the documentation of this file.
1 #ifndef GAUDIMATH_NUMERICALINDEFINITEINTEGRAL_H
2 #define GAUDIMATH_NUMERICALINDEFINITEINTEGRAL_H 1
3 // ============================================================================
4 // Include files
5 // ============================================================================
6 // STD & STL
7 // ============================================================================
8 #include <string>
9 // ============================================================================
10 // GaudiKernel
11 // ============================================================================
12 #include "GaudiKernel/StatusCode.h"
13 // ============================================================================
14 // GaudiMath
15 // ============================================================================
16 #include "GaudiMath/Integration.h"
17 // ============================================================================
18 // CLHEP
19 // ============================================================================
20 #include "CLHEP/GenericFunctions/AbsFunction.hh"
21 // ============================================================================
22 #include "gsl/gsl_integration.h"
23 
24 
26 
27 namespace Genfun
28 {
29  namespace GaudiMathImplementation
30  {
75  class GAUDI_API NumericalIndefiniteIntegral : public AbsFunction
76  {
77  public:
78  struct _Workspace { gsl_integration_workspace* ws ; };
79  struct _Function ;
80  public:
81 
83  typedef std::vector<double> Points ;
84 
85  public:
86 
88  FUNCTION_OBJECT_DEF( NumericalIndefiniteIntegral )
89 
90  public:
91 
156  ( const AbsFunction& function ,
157  const size_t index ,
158  const double a ,
159  const GaudiMath::Integration::Limit limit =
161  const GaudiMath::Integration::Type type =
163  const GaudiMath::Integration::KronrodRule rule =
165  const double epsabs = 1e-10 ,
166  const double epsrel = 1.e-7 ,
167  const size_t size = 1000 );
168 
211  ( const AbsFunction& function ,
212  const size_t index ,
213  const double a ,
214  const Points& points ,
215  const GaudiMath::Integration::Limit limit =
216  GaudiMath::Integration::VariableHighLimit ,
217  const double epsabs = 1e-9 ,
218  const double epsrel = 1.e-6 ,
219  const size_t size = 1000 ) ;
220 
259  ( const AbsFunction& function ,
260  const size_t index ,
261  const GaudiMath::Integration::Limit limit =
262  GaudiMath::Integration::VariableHighLimit ,
263  const double epsabs = 1e-9 ,
264  const double epsrel = 1.e-6 ,
265  const size_t size = 1000 ) ;
266 
269  ( const NumericalIndefiniteIntegral& ) ;
270 
272  virtual ~NumericalIndefiniteIntegral() = default;
273 
274  public:
275 
277  virtual unsigned int dimensionality() const { return m_DIM ; }
278 
280  virtual double operator() ( double argument ) const ;
282  virtual double operator() ( const Argument& argument ) const ;
283 
285  virtual bool hasAnalyticDerivative() const { return true ;}
286 
288  virtual Genfun::Derivative partial ( unsigned int index ) const;
289 
290  public:
291 
293  const AbsFunction& function () const { return *m_function ; }
295  double a () const { return m_a ; }
297  const Points& points () const { return m_points ; }
299  double epsabs () const { return m_epsabs ; }
301  double epsrel () const { return m_epsrel ; }
302 
304  double result () const { return m_result ; }
306  double error () const { return m_error ; }
307 
308  // maximal number of bisection integvals for adaptive algorithms
309  size_t size () const { return m_size ; }
310 
313  limit () const { return m_limit ; }
316  type () const { return m_type ; }
319  category () const { return m_category ; }
322  rule () const { return m_rule ; }
323 
324  protected:
325 
326  // adaptive integration on infinite intervals
327  double QAGI ( _Function* fun ) const ;
328  // adaptive integration with known singular points
329  double QAGP ( _Function* fun ) const ;
330  // non-adaptive integration
331  double QNG ( _Function* fun ) const ;
332  // adaptive integration
333  double QAG ( _Function* fun ) const ;
334  // adaptive integral with singularities
335  double QAGS ( _Function* fun ) const ;
336 
337  // allocate the integration workspace
338  _Workspace* allocate () const ;
339  // the integration workspace
340  _Workspace* ws () const
341  { return m_ws.get(); }
342 
343  // throw the exception
344  StatusCode Exception
345  ( const std::string& message ,
346  const StatusCode& sc = StatusCode::FAILURE ) const ;
347 
348  private:
349 
350  // default constructor is disabled
352  // assignement operator is disabled
353  NumericalIndefiniteIntegral& operator=
354  ( const NumericalIndefiniteIntegral& ) ;
355 
356  public:
357 
358  struct gsl_ws_deleter {
359  void operator()(_Workspace* p) const {
360  if (p) gsl_integration_workspace_free ( p->ws ) ;
361  delete p;
362  }
363  };
364  private:
365 
367  size_t m_DIM ;
368  size_t m_index ;
369 
370  double m_a ;
371 
376 
377  Points m_points ;
379 
380  double m_epsabs ;
381  double m_epsrel ;
382 
383  mutable double m_result ;
384  mutable double m_error ;
385 
386  size_t m_size ;
388 
389  mutable Argument m_argument ;
390 
391  };
392 
393  } // end of namespace GaudiMathImplementation
394 } // end of namespace Genfun
395 
396 // ============================================================================
397 // The END
398 // ============================================================================
399 #endif // GAUDIMATH_NUMERICALINDEFINITEINTEGRAL_H
400 // ============================================================================
Category
integration category
Definition: Integration.h:30
GaudiMath::Integration::Limit limit() const
integration limit
Genfun::GaudiMathImplementation::NumericalDerivative Derivative
Definition: GaudiMath.h:29
virtual bool hasAnalyticDerivative() const
Does this function have an analytic derivative?
GaudiMath::Integration::Category category() const
integration category
STL class.
string type
Definition: gaudirun.py:151
GaudiMath::Integration::KronrodRule rule() const
integration rule
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Type
type of integration (for finite limits)
Definition: Integration.h:25
GaudiMath::Integration::Type type() const
integration type
Limit
how to distinguish variable low and variable high limits
Definition: Integration.h:22
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:26
GaudiMath.h GaudiMath/GaudiMath.h.
Definition: Adapters.h:13
KronrodRule
integration rule
Definition: Integration.h:34
std::vector< double > Points
typedef for vector of singular points
CLHEP.
Definition: IEqSolver.h:13
#define GAUDI_API
Definition: Kernel.h:107
Type
the list of available types for ntuples
Definition: TupleObj.h:79
collection of common types for classes NumericalIndefiniteIntegral and NumericalDefiniteIntegral ...