| The Gaudi Framework v28r2p1 (f1a77ff4)

- 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 { gsl_integration_workspace* ws ; };
83 struct _Function ;
84 public:
85
87 typedef std::vector<double> Points ;
88
89 public:
90
92 FUNCTION_OBJECT_DEF( NumericalDefiniteIntegral )
93
94 public:
95
147 NumericalDefiniteIntegral
148 ( const AbsFunction& function ,
149 const size_t index ,
150 const double a ,
151 const double b ,
152 const GaudiMath::Integration::Type type =
153 GaudiMath::Integration::Adaptive ,
154 const GaudiMath::Integration::KronrodRule rule =
155 GaudiMath::Integration::Default ,
156 const double epsabs = 1.e-10 ,
157 const double epsrel = 1.e-7 ,
158 const size_t size = 1000 );
159
160
189 NumericalDefiniteIntegral
190 ( const AbsFunction& function ,
191 const size_t index ,
192 const double a ,
193 const double b ,
194 const Points& points ,
195 const double epsabs = 1e-9 ,
196 const double epsrel = 1.e-6 ,
197 const size_t size = 1000 ) ;
198
199
225 NumericalDefiniteIntegral
226 ( const AbsFunction& function ,
227 const size_t index ,
228 const double a ,
229 const GaudiMath::Integration::Inf b =
230 GaudiMath::Integration::Infinity ,
231 const double epsabs = 1e-9 ,
232 const double epsrel = 1.e-6 ,
233 const size_t size = 1000 ) ;
234
260 NumericalDefiniteIntegral
261 ( const AbsFunction& function ,
262 const size_t index ,
263 const GaudiMath::Integration::Inf a ,
264 const double b ,
265 const double epsabs = 1e-9 ,
266 const double epsrel = 1.e-6 ,
267 const size_t size = 1000 ) ;
268
292 NumericalDefiniteIntegral
293 ( const AbsFunction& function ,
294 const size_t index ,
295 // FIXME: The next two arguments should be "double" but are "float" to resolve the
296 // ambiguity with the first constructor when providing
297 // '(const Genfun::AbsFunction, const unsigned int, const double, const double)'
298 const float epsabs = 1e-9 ,
299 const float epsrel = 1.e-6 ,
300 const size_t size = 1000 ) ;
301
303 NumericalDefiniteIntegral ( const NumericalDefiniteIntegral& ) ;
304
306 ~NumericalDefiniteIntegral() override = default;
307
308 public:
309
311 unsigned int dimensionality() const override { return m_DIM ; }
312
314 double operator() ( double argument ) const override ;
316 double operator() ( const Argument& argument ) const override ;
317
319 bool hasAnalyticDerivative() const override { return true ;}
320
322 Genfun::Derivative partial ( unsigned int index ) const override;
323
324 public:
325
327 const AbsFunction& function () const { return *m_function ; }
329 double a () const { return m_a ; }
330 double b () const { return m_b ; }
332 const Points& points () const { return m_points ; }
334 double epsabs () const { return m_epsabs ; }
336 double epsrel () const { return m_epsrel ; }
337
339 double result () const { return m_result ; }
341 double error () const { return m_error ; }
342
343 // maximal number of bisection integvals for adaptive algorithms
344 size_t size () const { return m_size ; }
345
347 GaudiMath::Integration::Type
348 type () const { return m_type ; }
350 GaudiMath::Integration::Category
351 category () const { return m_category ; }
353 GaudiMath::Integration::KronrodRule
354 rule () const { return m_rule ; }
355
356 protected:
357
358 // adaptive integration on infinite intervals
359 double QAGI ( _Function* fun ) const ;
360 // adaptive integration with known singular points
361 double QAGP ( _Function* fun ) const ;
362 // non-adaptive integration
363 double QNG ( _Function* fun ) const ;
364 // adaptive integration
365 double QAG ( _Function* fun ) const ;
366 // adaptive integral with singularities
367 double QAGS ( _Function* fun ) const ;
368
369 // allocate the integration workspace
370 _Workspace* allocate () const ;
371 // the integration workspace
372 _Workspace* ws () const
373 { return m_ws.get() ; };
374
375 // throw the exception
376 StatusCode Exception
377 ( const std::string& message ,
378 const StatusCode& sc = StatusCode::FAILURE ) const ;
379
380 private:
381
382 // defautl constructor is disabled
383 NumericalDefiniteIntegral();
384 // assignement is disabled
385 NumericalDefiniteIntegral& operator=( const NumericalDefiniteIntegral& );
386
387 public:
388 struct gsl_ws_deleter {
389 void operator()(_Workspace *p) const {
390 if (p) gsl_integration_workspace_free ( p->ws ) ;
391 delete p;
392 }
393 };
394 private:
395
396 std::unique_ptr<const AbsFunction> m_function ;
397 size_t m_DIM ;
398 size_t m_index ;
399
400 double m_a ;
401 double m_b ;
402 bool m_ia ;
403 bool m_ib ;
404
405 GaudiMath::Integration::Type m_type ;
406 GaudiMath::Integration::Category m_category ;
407 GaudiMath::Integration::KronrodRule m_rule ;
408
409 Points m_points ;
410 std::unique_ptr<double[]> m_pdata ;
411
412 double m_epsabs ;
413 double m_epsrel ;
414
415 mutable double m_result ;
416 mutable double m_error ;
417
418 size_t m_size ;
419 mutable std::unique_ptr<_Workspace,gsl_ws_deleter> m_ws;
420
421 mutable Argument m_argument ;
422 mutable Argument m_argF ;
423
424 };
426 FUNCTION_OBJECT_IMP( NumericalDefiniteIntegral )
427
428 } // end of namespace GaudiMathImplementation
429 } // end of namespace Genfun
430
431 #if defined(__clang__) || defined(__CLING__)
432 #pragma clang diagnostic pop
433 #elif defined(__GNUC__) && __GNUC__ >= 5
434 #pragma GCC diagnostic pop
435 #endif
436
437 // ============================================================================
438 // The END
439 // ============================================================================
440 #endif // GAUDIMATH_NUMERICALDEFINITEINTEGRAL_H
441 // ============================================================================
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_epsabs
double m_epsabs
Definition: NumericalDefiniteIntegral.h:412
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::size
size_t size() const
Definition: NumericalDefiniteIntegral.h:344
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::category
GaudiMath::Integration::Category category() const
integration category
Definition: NumericalDefiniteIntegral.h:351
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_error
double m_error
Definition: NumericalDefiniteIntegral.h:416
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::_Workspace
Definition: NumericalDefiniteIntegral.h:82
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::ws
_Workspace * ws() const
Definition: NumericalDefiniteIntegral.h:372
StatusCode::FAILURE
Definition: StatusCode.h:29
gaudirun.default
default
Definition: gaudirun.py:141
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::_Workspace::ws
gsl_integration_workspace * ws
Definition: NumericalDefiniteIntegral.h:82
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_category
GaudiMath::Integration::Category m_category
Definition: NumericalDefiniteIntegral.h:406
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_epsrel
double m_epsrel
Definition: NumericalDefiniteIntegral.h:413
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_size
size_t m_size
Definition: NumericalDefiniteIntegral.h:418
GaudiMath::Integration::Inf
Inf
infinity
Definition: Integration.h:20
GaudiMath::Integration::Category
Category
integration category
Definition: Integration.h:30
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::result
double result() const
previous result
Definition: NumericalDefiniteIntegral.h:339
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_b
double m_b
Definition: NumericalDefiniteIntegral.h:401
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_DIM
size_t m_DIM
Definition: NumericalDefiniteIntegral.h:397
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_ws
std::unique_ptr< _Workspace, gsl_ws_deleter > m_ws
Definition: NumericalDefiniteIntegral.h:419
GaudiMath::Integration::Infinity
Definition: Integration.h:20
GaudiMath::Integration::Adaptive
Definition: Integration.h:26
GaudiMath::Derivative
Genfun::GaudiMathImplementation::NumericalDerivative Derivative
Definition: GaudiMath.h:29
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::gsl_ws_deleter
Definition: NumericalDefiniteIntegral.h:388
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:319
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_index
size_t m_index
Definition: NumericalDefiniteIntegral.h:398
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::epsabs
double epsabs() const
absolute precision
Definition: NumericalDefiniteIntegral.h:334
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_points
Points m_points
Definition: NumericalDefiniteIntegral.h:409
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_rule
GaudiMath::Integration::KronrodRule m_rule
Definition: NumericalDefiniteIntegral.h:407
Integration.h
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
GaudiMath::Integration::Type
Type
type of integration (for finite limits)
Definition: Integration.h:25
gaudirun.type
type
Definition: gaudirun.py:125
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_ia
bool m_ia
Definition: NumericalDefiniteIntegral.h:402
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_result
double m_result
Definition: NumericalDefiniteIntegral.h:415
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::error
double error() const
evaluate of previous error
Definition: NumericalDefiniteIntegral.h:341
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_pdata
std::unique_ptr< double[]> m_pdata
Definition: NumericalDefiniteIntegral.h:410
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::_Function
Definition: NumericalDefiniteIntegral.cpp:46
GaudiMath::Integration::Default
Definition: Integration.h:41
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::epsrel
double epsrel() const
relatiove precision
Definition: NumericalDefiniteIntegral.h:336
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_a
double m_a
Definition: NumericalDefiniteIntegral.h:400
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::gsl_ws_deleter::operator()
void operator()(_Workspace *p) const
Definition: NumericalDefiniteIntegral.h:389
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_type
GaudiMath::Integration::Type m_type
Definition: NumericalDefiniteIntegral.h:405
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::type
GaudiMath::Integration::Type type() const
integration type
Definition: NumericalDefiniteIntegral.h:348
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_function
std::unique_ptr< const AbsFunction > m_function
Definition: NumericalDefiniteIntegral.h:396
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::Points
std::vector< double > Points
typedef for vector of singular points
Definition: NumericalDefiniteIntegral.h:83
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:332
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:422
GaudiMath::Integration::KronrodRule
KronrodRule
integration rule
Definition: Integration.h:34
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_ib
bool m_ib
Definition: NumericalDefiniteIntegral.h:403
Genfun
CLHEP.
Definition: IEqSolver.h:13
StatusCode.h
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::b
double b() const
Definition: NumericalDefiniteIntegral.h:330
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_argument
Argument m_argument
Definition: NumericalDefiniteIntegral.h:421
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:107
Tuples::Type
Type
the list of available types for ntuples
Definition: TupleObj.h:79
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::rule
GaudiMath::Integration::KronrodRule rule() const
integration rule
Definition: NumericalDefiniteIntegral.h:354
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::a
double a() const
integration limit
Definition: NumericalDefiniteIntegral.h:329
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