Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
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 <memory>
9 #include <string>
10 // ============================================================================
11 // GaudiKernel
12 // ============================================================================
13 #include "GaudiKernel/StatusCode.h"
14 // ============================================================================
15 // GaudiMath
16 // ============================================================================
17 #include "GaudiMath/Integration.h"
18 // ============================================================================
19 // CLHEP
20 // ============================================================================
21 #include "CLHEP/GenericFunctions/AbsFunction.hh"
22 // ============================================================================
23 #include "gsl/gsl_integration.h"
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  namespace GaudiMathImplementation {
81  class GAUDI_API NumericalIndefiniteIntegral : public AbsFunction {
82  public:
83  struct _Workspace {
84  gsl_integration_workspace* ws;
85  };
86  struct _Function;
87 
88  public:
91 
92  public:
94  FUNCTION_OBJECT_DEF( NumericalIndefiniteIntegral )
95 
96  public:
161  const AbsFunction& function, const size_t index, const double a,
164  const GaudiMath::Integration::KronrodRule rule = GaudiMath::Integration::Default, const double epsabs = 1e-10,
165  const double epsrel = 1.e-7, const size_t size = 1000 );
166 
209  const AbsFunction& function, const size_t index, const double a, const Points& points,
210  const GaudiMath::Integration::Limit limit = GaudiMath::Integration::VariableHighLimit,
211  const double epsabs = 1e-9, const double epsrel = 1.e-6, const size_t size = 1000 );
212 
251  const AbsFunction& function, const size_t index,
252  const GaudiMath::Integration::Limit limit = GaudiMath::Integration::VariableHighLimit,
253  const double epsabs = 1e-9, const double epsrel = 1.e-6, const size_t size = 1000 );
254 
257 
258  public:
260  unsigned int dimensionality() const override { return m_DIM; }
261 
263  double operator()( double argument ) const override;
265  double operator()( const Argument& argument ) const override;
266 
268  bool hasAnalyticDerivative() const override { return true; }
269 
271  Genfun::Derivative partial( unsigned int index ) const override;
272 
273  public:
275  const AbsFunction& function() const { return *m_function; }
277  double a() const { return m_a; }
279  const Points& points() const { return m_points; }
281  double epsabs() const { return m_epsabs; }
283  double epsrel() const { return m_epsrel; }
284 
286  double result() const { return m_result; }
288  double error() const { return m_error; }
289 
290  // maximal number of bisection integvals for adaptive algorithms
291  size_t size() const { return m_size; }
292 
294  GaudiMath::Integration::Limit limit() const { return m_limit; }
296  GaudiMath::Integration::Type type() const { return m_type; }
298  GaudiMath::Integration::Category category() const { return m_category; }
300  GaudiMath::Integration::KronrodRule rule() const { return m_rule; }
301 
302  protected:
303  // adaptive integration on infinite intervals
304  double QAGI( _Function* fun ) const;
305  // adaptive integration with known singular points
306  double QAGP( _Function* fun ) const;
307  // non-adaptive integration
308  double QNG( _Function* fun ) const;
309  // adaptive integration
310  double QAG( _Function* fun ) const;
311  // adaptive integral with singularities
312  double QAGS( _Function* fun ) const;
313 
314  // allocate the integration workspace
315  _Workspace* allocate() const;
316  // the integration workspace
317  _Workspace* ws() const { return m_ws.get(); }
318 
319  // throw the exception
320  StatusCode Exception( const std::string& message, const StatusCode& sc = StatusCode::FAILURE ) const;
321 
322  private:
323  // default constructor is disabled
325  // assignement operator is disabled
327 
328  public:
329  struct gsl_ws_deleter {
330  void operator()( _Workspace* p ) const {
331  if ( p ) gsl_integration_workspace_free( p->ws );
332  delete p;
333  }
334  };
335 
336  private:
338  size_t m_DIM;
339  size_t m_index;
340 
341  double m_a;
342 
347 
348  Points m_points;
349 
350  double m_epsabs;
351  double m_epsrel;
352 
353  mutable double m_result = GSL_NEGINF;
354  mutable double m_error = GSL_POSINF;
355 
356  size_t m_size;
358 
359  mutable Argument m_argument;
360  };
362  FUNCTION_OBJECT_IMP( NumericalIndefiniteIntegral )
363 
364  } // end of namespace GaudiMathImplementation
365 } // end of namespace Genfun
366 
367 #if defined( __clang__ ) || defined( __CLING__ )
368 # pragma clang diagnostic pop
369 #elif defined( __GNUC__ ) && __GNUC__ >= 5
370 # pragma GCC diagnostic pop
371 #endif
372 
373 // ============================================================================
374 // The END
375 // ============================================================================
376 #endif // GAUDIMATH_NUMERICALINDEFINITEINTEGRAL_H
Category
integration category
Definition: Integration.h:24
GaudiMath::Integration::Limit limit() const
integration limit
Genfun::GaudiMathImplementation::NumericalDerivative Derivative
Definition: GaudiMath.h:26
constexpr auto size(const C &c) noexcept(noexcept(c.size())) -> decltype(c.size())
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:50
Type
type of integration (for finite limits)
Definition: Integration.h:22
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:20
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:26
constexpr static const auto FAILURE
Definition: StatusCode.h:86
GaudiMath.h GaudiMath/GaudiMath.h.
Definition: Adapters.h:13
KronrodRule
integration rule
Definition: Integration.h:26
std::vector< double > Points
typedef for vector of singular points
CLHEP.
Definition: IEqSolver.h:13
#define GAUDI_API
Definition: Kernel.h:71
Type
the list of available types for ntuples
Definition: TupleObj.h:80
collection of common types for classes NumericalIndefiniteIntegral and NumericalDefiniteIntegral ...