| The Gaudi Framework v29r1 (5cd95fa2)

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

- File List
- File Members

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:
92 typedef std::vector<double> Points;
93
94 public:
96 FUNCTION_OBJECT_DEF( NumericalIndefiniteIntegral )
97
98 public:
162 NumericalIndefiniteIntegral(
163 const AbsFunction& function, const size_t index, const double a,
164 const GaudiMath::Integration::Limit limit = GaudiMath::Integration::VariableHighLimit,
165 const GaudiMath::Integration::Type type = GaudiMath::Integration::Adaptive,
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
210 NumericalIndefiniteIntegral(
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
252 NumericalIndefiniteIntegral(
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
258 NumericalIndefiniteIntegral( const NumericalIndefiniteIntegral& );
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
329 NumericalIndefiniteIntegral();
330 // assignement operator is disabled
331 NumericalIndefiniteIntegral& operator=( const NumericalIndefiniteIntegral& );
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:
343 std::unique_ptr<const AbsFunction> m_function;
344 size_t m_DIM;
345 size_t m_index;
346
347 double m_a;
348
349 GaudiMath::Integration::Limit m_limit;
350 GaudiMath::Integration::Type m_type;
351 GaudiMath::Integration::Category m_category;
352 GaudiMath::Integration::KronrodRule m_rule;
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;
363 mutable std::unique_ptr<_Workspace, gsl_ws_deleter> m_ws;
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 // ============================================================================
StatusCode::FAILURE
Definition: StatusCode.h:31
gaudirun.default
default
Definition: gaudirun.py:149
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::epsrel
double epsrel() const
relatiove precision
Definition: NumericalIndefiniteIntegral.h:288
GaudiMath::Integration::Category
Category
integration category
Definition: Integration.h:26
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::result
double result() const
previous result
Definition: NumericalIndefiniteIntegral.h:291
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::error
double error() const
evaluate of previous error
Definition: NumericalIndefiniteIntegral.h:293
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_index
size_t m_index
Definition: NumericalIndefiniteIntegral.h:345
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_a
double m_a
Definition: NumericalIndefiniteIntegral.h:347
GaudiMath::Integration::Adaptive
Definition: Integration.h:24
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::limit
GaudiMath::Integration::Limit limit() const
integration limit
Definition: NumericalIndefiniteIntegral.h:299
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::size
size_t size() const
Definition: NumericalIndefiniteIntegral.h:296
GaudiMath::Derivative
Genfun::GaudiMathImplementation::NumericalDerivative Derivative
Definition: GaudiMath.h:27
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::_Workspace::ws
gsl_integration_workspace * ws
Definition: NumericalIndefiniteIntegral.h:86
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::category
GaudiMath::Integration::Category category() const
integration category
Definition: NumericalIndefiniteIntegral.h:303
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::gsl_ws_deleter
Definition: NumericalIndefiniteIntegral.h:334
operator=
PropertyMgr & operator=(const PropertyMgr &)=delete
std::string
STL class.
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_epsabs
double m_epsabs
Definition: NumericalIndefiniteIntegral.h:356
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_size
size_t m_size
Definition: NumericalIndefiniteIntegral.h:362
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_DIM
size_t m_DIM
Definition: NumericalIndefiniteIntegral.h:344
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::rule
GaudiMath::Integration::KronrodRule rule() const
integration rule
Definition: NumericalIndefiniteIntegral.h:305
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::_Function
Definition: NumericalIndefiniteIntegral.cpp:52
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
GaudiMath::Integration::VariableHighLimit
Definition: Integration.h:22
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_epsrel
double m_epsrel
Definition: NumericalIndefiniteIntegral.h:357
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::_Workspace
Definition: NumericalIndefiniteIntegral.h:85
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::epsabs
double epsabs() const
absolute precision
Definition: NumericalIndefiniteIntegral.h:286
GaudiMath::Integration::Default
Definition: Integration.h:36
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::hasAnalyticDerivative
bool hasAnalyticDerivative() const override
Does this function have an analytic derivative?
Definition: NumericalIndefiniteIntegral.h:273
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_limit
GaudiMath::Integration::Limit m_limit
Definition: NumericalIndefiniteIntegral.h:349
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_category
GaudiMath::Integration::Category m_category
Definition: NumericalIndefiniteIntegral.h:351
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::type
GaudiMath::Integration::Type type() const
integration type
Definition: NumericalIndefiniteIntegral.h:301
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_function
std::unique_ptr< const AbsFunction > m_function
Definition: NumericalIndefiniteIntegral.h:343
std::vector< double >
std::unique_ptr< const AbsFunction >
Gaudi::Functional::operator()
virtual Out operator()(const vector_of_const_< In > &inputs) const =0
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::a
double a() const
integration limit
Definition: NumericalIndefiniteIntegral.h:282
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_type
GaudiMath::Integration::Type m_type
Definition: NumericalIndefiniteIntegral.h:350
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_argument
Argument m_argument
Definition: NumericalIndefiniteIntegral.h:365
GaudiMath::Integration::Limit
Limit
how to distinguish variable low and variable high limits
Definition: Integration.h:22
fun
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:26
GaudiMath
GaudiMath.h GaudiMath/GaudiMath.h.
Definition: Adapters.h:13
GaudiMath::Integration::KronrodRule
KronrodRule
integration rule
Definition: Integration.h:28
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::Points
std::vector< double > Points
typedef for vector of singular points
Definition: NumericalIndefiniteIntegral.h:88
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_rule
GaudiMath::Integration::KronrodRule m_rule
Definition: NumericalIndefiniteIntegral.h:352
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_ws
std::unique_ptr< _Workspace, gsl_ws_deleter > m_ws
Definition: NumericalIndefiniteIntegral.h:363
Genfun
CLHEP.
Definition: IEqSolver.h:13
StatusCode.h
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral
The simple class for numerical integrations.
Definition: NumericalIndefiniteIntegral.h:82
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::NumericalIndefiniteIntegral::points
const Points & points() const
known singularities
Definition: NumericalIndefiniteIntegral.h:284
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::gsl_ws_deleter::operator()
void operator()(_Workspace *p) const
Definition: NumericalIndefiniteIntegral.h:335
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::ws
_Workspace * ws() const
Definition: NumericalIndefiniteIntegral.h:322
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_points
Points m_points
Definition: NumericalIndefiniteIntegral.h:354
Integration
collection of common types for classes NumericalIndefiniteIntegral and NumericalDefiniteIntegral ...