The Gaudi Framework  v29r0 (ff2e7097)
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 #if defined( __clang__ ) || defined( __CLING__ )
25 #pragma clang diagnostic push
26 #pragma clang diagnostic ignored "-Winconsistent-missing-override"
27 #elif defined( __GNUC__ ) && __GNUC__ >= 5
28 #pragma GCC diagnostic push
29 #pragma GCC diagnostic ignored "-Wsuggest-override"
30 #endif
31 
33 
34 namespace Genfun
35 {
36  namespace GaudiMathImplementation
37  {
82  class GAUDI_API NumericalIndefiniteIntegral : public AbsFunction
83  {
84  public:
85  struct _Workspace {
86  gsl_integration_workspace* ws;
87  };
88  struct _Function;
89 
90  public:
93 
94  public:
96  FUNCTION_OBJECT_DEF( NumericalIndefiniteIntegral )
97 
98  public:
163  const AbsFunction& function, const size_t index, const double a,
166  const GaudiMath::Integration::KronrodRule rule = GaudiMath::Integration::Default, const double epsabs = 1e-10,
167  const double epsrel = 1.e-7, const size_t size = 1000 );
168 
211  const AbsFunction& function, const size_t index, const double a, const Points& points,
212  const GaudiMath::Integration::Limit limit = GaudiMath::Integration::VariableHighLimit,
213  const double epsabs = 1e-9, const double epsrel = 1.e-6, const size_t size = 1000 );
214 
253  const AbsFunction& function, const size_t index,
254  const GaudiMath::Integration::Limit limit = GaudiMath::Integration::VariableHighLimit,
255  const double epsabs = 1e-9, const double epsrel = 1.e-6, const size_t size = 1000 );
256 
259 
261  ~NumericalIndefiniteIntegral() override = default;
262 
263  public:
265  unsigned int dimensionality() const override { return m_DIM; }
266 
268  double operator()( double argument ) const override;
270  double operator()( const Argument& argument ) const override;
271 
273  bool hasAnalyticDerivative() const override { return true; }
274 
276  Genfun::Derivative partial( unsigned int index ) const override;
277 
278  public:
280  const AbsFunction& function() const { return *m_function; }
282  double a() const { return m_a; }
284  const Points& points() const { return m_points; }
286  double epsabs() const { return m_epsabs; }
288  double epsrel() const { return m_epsrel; }
289 
291  double result() const { return m_result; }
293  double error() const { return m_error; }
294 
295  // maximal number of bisection integvals for adaptive algorithms
296  size_t size() const { return m_size; }
297 
299  GaudiMath::Integration::Limit limit() const { return m_limit; }
301  GaudiMath::Integration::Type type() const { return m_type; }
303  GaudiMath::Integration::Category category() const { return m_category; }
305  GaudiMath::Integration::KronrodRule rule() const { return m_rule; }
306 
307  protected:
308  // adaptive integration on infinite intervals
309  double QAGI( _Function* fun ) const;
310  // adaptive integration with known singular points
311  double QAGP( _Function* fun ) const;
312  // non-adaptive integration
313  double QNG( _Function* fun ) const;
314  // adaptive integration
315  double QAG( _Function* fun ) const;
316  // adaptive integral with singularities
317  double QAGS( _Function* fun ) const;
318 
319  // allocate the integration workspace
320  _Workspace* allocate() const;
321  // the integration workspace
322  _Workspace* ws() const { return m_ws.get(); }
323 
324  // throw the exception
325  StatusCode Exception( const std::string& message, const StatusCode& sc = StatusCode::FAILURE ) const;
326 
327  private:
328  // default constructor is disabled
330  // assignement operator is disabled
332 
333  public:
334  struct gsl_ws_deleter {
335  void operator()( _Workspace* p ) const
336  {
337  if ( p ) gsl_integration_workspace_free( p->ws );
338  delete p;
339  }
340  };
341 
342  private:
344  size_t m_DIM;
345  size_t m_index;
346 
347  double m_a;
348 
353 
354  Points m_points;
355 
356  double m_epsabs;
357  double m_epsrel;
358 
359  mutable double m_result = GSL_NEGINF;
360  mutable double m_error = GSL_POSINF;
361 
362  size_t m_size;
364 
365  mutable Argument m_argument;
366  };
368  FUNCTION_OBJECT_IMP( NumericalIndefiniteIntegral )
369 
370  } // end of namespace GaudiMathImplementation
371 } // end of namespace Genfun
372 
373 #if defined( __clang__ ) || defined( __CLING__ )
374 #pragma clang diagnostic pop
375 #elif defined( __GNUC__ ) && __GNUC__ >= 5
376 #pragma GCC diagnostic pop
377 #endif
378 
379 // ============================================================================
380 // The END
381 // ============================================================================
382 #endif // GAUDIMATH_NUMERICALINDEFINITEINTEGRAL_H
383 // ============================================================================
Category
integration category
Definition: Integration.h:26
GaudiMath::Integration::Limit limit() const
integration limit
Genfun::GaudiMathImplementation::NumericalDerivative Derivative
Definition: GaudiMath.h:27
GaudiMath::Integration::Category category() const
integration category
PropertyMgr & operator=(const PropertyMgr &)=delete
STL class.
GaudiMath::Integration::KronrodRule rule() const
integration rule
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
Type
type of integration (for finite limits)
Definition: Integration.h:24
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:28
std::vector< double > Points
typedef for vector of singular points
CLHEP.
Definition: IEqSolver.h:13
#define GAUDI_API
Definition: Kernel.h:110
Type
the list of available types for ntuples
Definition: TupleObj.h:84
collection of common types for classes NumericalIndefiniteIntegral and NumericalDefiniteIntegral ...