All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
25 #if defined(__clang__) || defined(__CLING__)
26 #pragma clang diagnostic push
27 #pragma clang diagnostic ignored "-Winconsistent-missing-override"
28 #elif defined(__GNUC__) && __GNUC__ >= 5
29 #pragma GCC diagnostic push
30 #pragma GCC diagnostic ignored "-Wsuggest-override"
31 #endif
32 
34 
35 namespace Genfun
36 {
37  namespace GaudiMathImplementation
38  {
83  class GAUDI_API NumericalIndefiniteIntegral : public AbsFunction
84  {
85  public:
86  struct _Workspace { gsl_integration_workspace* ws ; };
87  struct _Function ;
88  public:
89 
91  typedef std::vector<double> Points ;
92 
93  public:
94 
96  FUNCTION_OBJECT_DEF( NumericalIndefiniteIntegral )
97 
98  public:
99 
164  ( const AbsFunction& function ,
165  const size_t index ,
166  const double a ,
167  const GaudiMath::Integration::Limit limit =
169  const GaudiMath::Integration::Type type =
171  const GaudiMath::Integration::KronrodRule rule =
173  const double epsabs = 1e-10 ,
174  const double epsrel = 1.e-7 ,
175  const size_t size = 1000 );
176 
219  ( const AbsFunction& function ,
220  const size_t index ,
221  const double a ,
222  const Points& points ,
223  const GaudiMath::Integration::Limit limit =
224  GaudiMath::Integration::VariableHighLimit ,
225  const double epsabs = 1e-9 ,
226  const double epsrel = 1.e-6 ,
227  const size_t size = 1000 ) ;
228 
267  ( const AbsFunction& function ,
268  const size_t index ,
269  const GaudiMath::Integration::Limit limit =
270  GaudiMath::Integration::VariableHighLimit ,
271  const double epsabs = 1e-9 ,
272  const double epsrel = 1.e-6 ,
273  const size_t size = 1000 ) ;
274 
277  ( const NumericalIndefiniteIntegral& ) ;
278 
280  ~NumericalIndefiniteIntegral() override = default;
281 
282  public:
283 
285  unsigned int dimensionality() const override { return m_DIM ; }
286 
288  double operator() ( double argument ) const override;
290  double operator() ( const Argument& argument ) const override;
291 
293  bool hasAnalyticDerivative() const override { return true ;}
294 
296  Genfun::Derivative partial ( unsigned int index ) const override;
297 
298  public:
299 
301  const AbsFunction& function () const { return *m_function ; }
303  double a () const { return m_a ; }
305  const Points& points () const { return m_points ; }
307  double epsabs () const { return m_epsabs ; }
309  double epsrel () const { return m_epsrel ; }
310 
312  double result () const { return m_result ; }
314  double error () const { return m_error ; }
315 
316  // maximal number of bisection integvals for adaptive algorithms
317  size_t size () const { return m_size ; }
318 
321  limit () const { return m_limit ; }
324  type () const { return m_type ; }
327  category () const { return m_category ; }
330  rule () const { return m_rule ; }
331 
332  protected:
333 
334  // adaptive integration on infinite intervals
335  double QAGI ( _Function* fun ) const ;
336  // adaptive integration with known singular points
337  double QAGP ( _Function* fun ) const ;
338  // non-adaptive integration
339  double QNG ( _Function* fun ) const ;
340  // adaptive integration
341  double QAG ( _Function* fun ) const ;
342  // adaptive integral with singularities
343  double QAGS ( _Function* fun ) const ;
344 
345  // allocate the integration workspace
346  _Workspace* allocate () const ;
347  // the integration workspace
348  _Workspace* ws () const
349  { return m_ws.get(); }
350 
351  // throw the exception
352  StatusCode Exception
353  ( const std::string& message ,
354  const StatusCode& sc = StatusCode::FAILURE ) const ;
355 
356  private:
357 
358  // default constructor is disabled
360  // assignement operator is disabled
361  NumericalIndefiniteIntegral& operator=
362  ( const NumericalIndefiniteIntegral& ) ;
363 
364  public:
365 
366  struct gsl_ws_deleter {
367  void operator()(_Workspace* p) const {
368  if (p) gsl_integration_workspace_free ( p->ws ) ;
369  delete p;
370  }
371  };
372  private:
373 
375  size_t m_DIM ;
376  size_t m_index ;
377 
378  double m_a ;
379 
384 
385  Points m_points ;
387 
388  double m_epsabs ;
389  double m_epsrel ;
390 
391  mutable double m_result ;
392  mutable double m_error ;
393 
394  size_t m_size ;
396 
397  mutable Argument m_argument ;
398 
399  };
401  FUNCTION_OBJECT_IMP( NumericalIndefiniteIntegral )
402 
403  } // end of namespace GaudiMathImplementation
404 } // end of namespace Genfun
405 
406 #if defined(__clang__) || defined(__CLING__)
407 #pragma clang diagnostic pop
408 #elif defined(__GNUC__) && __GNUC__ >= 5
409 #pragma GCC diagnostic pop
410 #endif
411 
412 // ============================================================================
413 // The END
414 // ============================================================================
415 #endif // GAUDIMATH_NUMERICALINDEFINITEINTEGRAL_H
416 // ============================================================================
Category
integration category
Definition: Integration.h:30
GaudiMath::Integration::Limit limit() const
integration limit
Genfun::GaudiMathImplementation::NumericalDerivative Derivative
Definition: GaudiMath.h:29
GaudiMath::Integration::Category category() const
integration category
STL class.
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
bool hasAnalyticDerivative() const override
Does this function have an analytic derivative?
GaudiMath::Integration::Type type() const
integration type
virtual Out operator()(const vector_of_const_< In > &inputs) const =0
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 ...