| The Gaudi Framework v29r0 (ff2e7097)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

NumericalDefiniteIntegral.h
Go to the documentation of this file.
1 #ifndef GAUDIMATH_NUMERICALDEFINITEINTEGRAL_H
2 #define GAUDIMATH_NUMERICALDEFINITEINTEGRAL_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
32 namespace Genfun
33 {
34 namespace GaudiMathImplementation
35 {
79 class GAUDI_API NumericalDefiniteIntegral : public AbsFunction
80 {
81 public:
82 struct _Workspace {
83 gsl_integration_workspace* ws;
84 };
85 struct _Function;
86
87 public:
89 typedef std::vector<double> Points;
90
91 public:
93 FUNCTION_OBJECT_DEF( NumericalDefiniteIntegral )
94
95 public:
147 NumericalDefiniteIntegral( const AbsFunction& function, const size_t index, const double a, const double b,
148 const GaudiMath::Integration::Type type = GaudiMath::Integration::Adaptive,
149 const GaudiMath::Integration::KronrodRule rule = GaudiMath::Integration::Default,
150 const double epsabs = 1.e-10, const double epsrel = 1.e-7, const size_t size = 1000 );
151
180 NumericalDefiniteIntegral( const AbsFunction& function, const size_t index, const double a, const double b,
181 const Points& points, const double epsabs = 1e-9, const double epsrel = 1.e-6,
182 const size_t size = 1000 );
183
209 NumericalDefiniteIntegral( const AbsFunction& function, const size_t index, const double a,
210 const GaudiMath::Integration::Inf b = GaudiMath::Integration::Infinity,
211 const double epsabs = 1e-9, const double epsrel = 1.e-6, const size_t size = 1000 );
212
238 NumericalDefiniteIntegral( const AbsFunction& function, const size_t index, const GaudiMath::Integration::Inf a,
239 const double b, const double epsabs = 1e-9, const double epsrel = 1.e-6,
240 const size_t size = 1000 );
241
265 NumericalDefiniteIntegral( const AbsFunction& function, const size_t index,
266 // FIXME: The next two arguments should be "double" but are "float" to resolve the
267 // ambiguity with the first constructor when providing
268 // '(const Genfun::AbsFunction, const unsigned int, const double, const double)'
269 const float epsabs = 1e-9, const float epsrel = 1.e-6, const size_t size = 1000 );
270
272 NumericalDefiniteIntegral( const NumericalDefiniteIntegral& );
273
275 ~NumericalDefiniteIntegral() override = default;
276
277 public:
279 unsigned int dimensionality() const override { return m_DIM; }
280
282 double operator()( double argument ) const override;
284 double operator()( const Argument& argument ) const override;
285
287 bool hasAnalyticDerivative() const override { return true; }
288
290 Genfun::Derivative partial( unsigned int index ) const override;
291
292 public:
294 const AbsFunction& function() const { return *m_function; }
296 double a() const { return m_a; }
297 double b() const { return m_b; }
299 const Points& points() const { return m_points; }
301 double epsabs() const { return m_epsabs; }
303 double epsrel() const { return m_epsrel; }
304
306 double result() const { return m_result; }
308 double error() const { return m_error; }
309
310 // maximal number of bisection integvals for adaptive algorithms
311 size_t size() const { return m_size; }
312
314 GaudiMath::Integration::Type type() const { return m_type; }
316 GaudiMath::Integration::Category category() const { return m_category; }
318 GaudiMath::Integration::KronrodRule rule() const { return m_rule; }
319
320 protected:
321 // adaptive integration on infinite intervals
322 double QAGI( _Function* fun ) const;
323 // adaptive integration with known singular points
324 double QAGP( _Function* fun ) const;
325 // non-adaptive integration
326 double QNG( _Function* fun ) const;
327 // adaptive integration
328 double QAG( _Function* fun ) const;
329 // adaptive integral with singularities
330 double QAGS( _Function* fun ) const;
331
332 // allocate the integration workspace
333 _Workspace* allocate() const;
334 // the integration workspace
335 _Workspace* ws() const { return m_ws.get(); };
336
337 // throw the exception
338 StatusCode Exception( const std::string& message, const StatusCode& sc = StatusCode::FAILURE ) const;
339
340 private:
341 // defautl constructor is disabled
342 NumericalDefiniteIntegral();
343 // assignement is disabled
344 NumericalDefiniteIntegral& operator=( const NumericalDefiniteIntegral& );
345
346 public:
347 struct gsl_ws_deleter {
348 void operator()( _Workspace* p ) const
349 {
350 if ( p ) gsl_integration_workspace_free( p->ws );
351 delete p;
352 }
353 };
354
355 private:
356 std::unique_ptr<const AbsFunction> m_function;
357 size_t m_DIM = 0;
358 size_t m_index;
359
360 double m_a = -std::numeric_limits<double>::infinity();
361 double m_b = std::numeric_limits<double>::infinity();
362
363 GaudiMath::Integration::Type m_type;
364 GaudiMath::Integration::Category m_category;
365 GaudiMath::Integration::KronrodRule m_rule;
366
367 Points m_points;
368
369 double m_epsabs;
370 double m_epsrel;
371
372 mutable double m_result = -std::numeric_limits<double>::infinity();
373 mutable double m_error = std::numeric_limits<double>::infinity();
374
375 size_t m_size;
376 mutable std::unique_ptr<_Workspace, gsl_ws_deleter> m_ws;
377
378 mutable Argument m_argument;
379 mutable Argument m_argF;
380 };
382 FUNCTION_OBJECT_IMP( NumericalDefiniteIntegral )
383
384 } // end of namespace GaudiMathImplementation
385 } // end of namespace Genfun
386
387 #if defined( __clang__ ) || defined( __CLING__ )
388 #pragma clang diagnostic pop
389 #elif defined( __GNUC__ ) && __GNUC__ >= 5
390 #pragma GCC diagnostic pop
391 #endif
392
393 // ============================================================================
394 // The END
395 // ============================================================================
396 #endif // GAUDIMATH_NUMERICALDEFINITEINTEGRAL_H
397 // ============================================================================
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_epsabs
double m_epsabs
Definition: NumericalDefiniteIntegral.h:369
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::size
size_t size() const
Definition: NumericalDefiniteIntegral.h:311
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::category
GaudiMath::Integration::Category category() const
integration category
Definition: NumericalDefiniteIntegral.h:316
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::_Workspace
Definition: NumericalDefiniteIntegral.h:82
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::ws
_Workspace * ws() const
Definition: NumericalDefiniteIntegral.h:335
StatusCode::FAILURE
Definition: StatusCode.h:31
gaudirun.default
default
Definition: gaudirun.py:149
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::_Workspace::ws
gsl_integration_workspace * ws
Definition: NumericalDefiniteIntegral.h:83
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_category
GaudiMath::Integration::Category m_category
Definition: NumericalDefiniteIntegral.h:364
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_epsrel
double m_epsrel
Definition: NumericalDefiniteIntegral.h:370
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_size
size_t m_size
Definition: NumericalDefiniteIntegral.h:375
GaudiMath::Integration::Inf
Inf
infinity
Definition: Integration.h:20
GaudiMath::Integration::Category
Category
integration category
Definition: Integration.h:26
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::result
double result() const
previous result
Definition: NumericalDefiniteIntegral.h:306
GaudiMath::Integration::Infinity
Definition: Integration.h:20
GaudiMath::Integration::Adaptive
Definition: Integration.h:24
GaudiMath::Derivative
Genfun::GaudiMathImplementation::NumericalDerivative Derivative
Definition: GaudiMath.h:27
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::gsl_ws_deleter
Definition: NumericalDefiniteIntegral.h:347
operator=
PropertyMgr & operator=(const PropertyMgr &)=delete
std::string
STL class.
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::hasAnalyticDerivative
bool hasAnalyticDerivative() const override
Does this function have an analytic derivative?
Definition: NumericalDefiniteIntegral.h:287
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_index
size_t m_index
Definition: NumericalDefiniteIntegral.h:358
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::epsabs
double epsabs() const
absolute precision
Definition: NumericalDefiniteIntegral.h:301
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_points
Points m_points
Definition: NumericalDefiniteIntegral.h:367
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_rule
GaudiMath::Integration::KronrodRule m_rule
Definition: NumericalDefiniteIntegral.h:365
Integration.h
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
GaudiMath::Integration::Type
Type
type of integration (for finite limits)
Definition: Integration.h:24
gaudirun.type
type
Definition: gaudirun.py:133
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::error
double error() const
evaluate of previous error
Definition: NumericalDefiniteIntegral.h:308
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::_Function
Definition: NumericalDefiniteIntegral.cpp:45
std::numeric_limits::infinity
T infinity(T...args)
GaudiMath::Integration::Default
Definition: Integration.h:36
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::epsrel
double epsrel() const
relatiove precision
Definition: NumericalDefiniteIntegral.h:303
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::gsl_ws_deleter::operator()
void operator()(_Workspace *p) const
Definition: NumericalDefiniteIntegral.h:348
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_type
GaudiMath::Integration::Type m_type
Definition: NumericalDefiniteIntegral.h:363
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_ws
std::unique_ptr< _Workspace, gsl_ws_deleter > m_ws
Definition: NumericalDefiniteIntegral.h:376
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::type
GaudiMath::Integration::Type type() const
integration type
Definition: NumericalDefiniteIntegral.h:314
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_function
std::unique_ptr< const AbsFunction > m_function
Definition: NumericalDefiniteIntegral.h:356
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::Points
std::vector< double > Points
typedef for vector of singular points
Definition: NumericalDefiniteIntegral.h:85
std::vector< double >
std::unique_ptr< const AbsFunction >
Gaudi::Functional::operator()
virtual Out operator()(const vector_of_const_< In > &inputs) const =0
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::points
const Points & points() const
known singularities
Definition: NumericalDefiniteIntegral.h:299
fun
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:26
GaudiMath
GaudiMath.h GaudiMath/GaudiMath.h.
Definition: Adapters.h:13
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_argF
Argument m_argF
Definition: NumericalDefiniteIntegral.h:379
GaudiMath::Integration::KronrodRule
KronrodRule
integration rule
Definition: Integration.h:28
Genfun
CLHEP.
Definition: IEqSolver.h:13
StatusCode.h
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::b
double b() const
Definition: NumericalDefiniteIntegral.h:297
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_argument
Argument m_argument
Definition: NumericalDefiniteIntegral.h:378
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:110
Tuples::Type
Type
the list of available types for ntuples
Definition: TupleObj.h:84
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::rule
GaudiMath::Integration::KronrodRule rule() const
integration rule
Definition: NumericalDefiniteIntegral.h:318
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::a
double a() const
integration limit
Definition: NumericalDefiniteIntegral.h:296
Integration
collection of common types for classes NumericalIndefiniteIntegral and NumericalDefiniteIntegral ...
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral
This class allows the numerical evaluation of the following functions:
Definition: NumericalDefiniteIntegral.h:79