| The Gaudi Framework v27r1

- 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 namespace Genfun
25 {
26 namespace GaudiMathImplementation
27 {
71 class GAUDI_API NumericalDefiniteIntegral : public AbsFunction
72 {
73 public:
74 struct _Workspace { gsl_integration_workspace* ws ; };
75 struct _Function ;
76 public:
77
79 typedef std::vector<double> Points ;
80
81 public:
82
84 FUNCTION_OBJECT_DEF( NumericalDefiniteIntegral )
85
86 public:
87
139 NumericalDefiniteIntegral
140 ( const AbsFunction& function ,
141 const size_t index ,
142 const double a ,
143 const double b ,
144 const GaudiMath::Integration::Type type =
145 GaudiMath::Integration::Adaptive ,
146 const GaudiMath::Integration::KronrodRule rule =
147 GaudiMath::Integration::Default ,
148 const double epsabs = 1.e-10 ,
149 const double epsrel = 1.e-7 ,
150 const size_t size = 1000 );
151
152
181 NumericalDefiniteIntegral
182 ( const AbsFunction& function ,
183 const size_t index ,
184 const double a ,
185 const double b ,
186 const Points& points ,
187 const double epsabs = 1e-9 ,
188 const double epsrel = 1.e-6 ,
189 const size_t size = 1000 ) ;
190
191
217 NumericalDefiniteIntegral
218 ( const AbsFunction& function ,
219 const size_t index ,
220 const double a ,
221 const GaudiMath::Integration::Inf b =
222 GaudiMath::Integration::Infinity ,
223 const double epsabs = 1e-9 ,
224 const double epsrel = 1.e-6 ,
225 const size_t size = 1000 ) ;
226
252 NumericalDefiniteIntegral
253 ( const AbsFunction& function ,
254 const size_t index ,
255 const GaudiMath::Integration::Inf a ,
256 const double b ,
257 const double epsabs = 1e-9 ,
258 const double epsrel = 1.e-6 ,
259 const size_t size = 1000 ) ;
260
284 NumericalDefiniteIntegral
285 ( const AbsFunction& function ,
286 const size_t index ,
287 // FIXME: The next two arguments should be "double" but are "float" to resolve the
288 // ambiguity with the first constructor when providing
289 // '(const Genfun::AbsFunction, const unsigned int, const double, const double)'
290 const float epsabs = 1e-9 ,
291 const float epsrel = 1.e-6 ,
292 const size_t size = 1000 ) ;
293
295 NumericalDefiniteIntegral ( const NumericalDefiniteIntegral& ) ;
296
298 virtual ~NumericalDefiniteIntegral() = default;
299
300 public:
301
303 virtual unsigned int dimensionality() const { return m_DIM ; }
304
306 virtual double operator() ( double argument ) const ;
308 virtual double operator() ( const Argument& argument ) const ;
309
311 virtual bool hasAnalyticDerivative() const { return true ;}
312
314 virtual Genfun::Derivative partial ( unsigned int index ) const;
315
316 public:
317
319 const AbsFunction& function () const { return *m_function ; }
321 double a () const { return m_a ; }
322 double b () const { return m_b ; }
324 const Points& points () const { return m_points ; }
326 double epsabs () const { return m_epsabs ; }
328 double epsrel () const { return m_epsrel ; }
329
331 double result () const { return m_result ; }
333 double error () const { return m_error ; }
334
335 // maximal number of bisection integvals for adaptive algorithms
336 size_t size () const { return m_size ; }
337
339 GaudiMath::Integration::Type
340 type () const { return m_type ; }
342 GaudiMath::Integration::Category
343 category () const { return m_category ; }
345 GaudiMath::Integration::KronrodRule
346 rule () const { return m_rule ; }
347
348 protected:
349
350 // adaptive integration on infinite intervals
351 double QAGI ( _Function* fun ) const ;
352 // adaptive integration with known singular points
353 double QAGP ( _Function* fun ) const ;
354 // non-adaptive integration
355 double QNG ( _Function* fun ) const ;
356 // adaptive integration
357 double QAG ( _Function* fun ) const ;
358 // adaptive integral with singularities
359 double QAGS ( _Function* fun ) const ;
360
361 // allocate the integration workspace
362 _Workspace* allocate () const ;
363 // the integration workspace
364 _Workspace* ws () const
365 { return m_ws.get() ; };
366
367 // throw the exception
368 StatusCode Exception
369 ( const std::string& message ,
370 const StatusCode& sc = StatusCode::FAILURE ) const ;
371
372 private:
373
374 // defautl constructor is disabled
375 NumericalDefiniteIntegral();
376 // assignement is disabled
377 NumericalDefiniteIntegral& operator=( const NumericalDefiniteIntegral& );
378
379 public:
380 struct gsl_ws_deleter {
381 void operator()(_Workspace *p) const {
382 if (p) gsl_integration_workspace_free ( p->ws ) ;
383 delete p;
384 }
385 };
386 private:
387
388 std::unique_ptr<const AbsFunction> m_function ;
389 size_t m_DIM ;
390 size_t m_index ;
391
392 double m_a ;
393 double m_b ;
394 bool m_ia ;
395 bool m_ib ;
396
397 GaudiMath::Integration::Type m_type ;
398 GaudiMath::Integration::Category m_category ;
399 GaudiMath::Integration::KronrodRule m_rule ;
400
401 Points m_points ;
402 std::unique_ptr<double[]> m_pdata ;
403
404 double m_epsabs ;
405 double m_epsrel ;
406
407 mutable double m_result ;
408 mutable double m_error ;
409
410 size_t m_size ;
411 mutable std::unique_ptr<_Workspace,gsl_ws_deleter> m_ws;
412
413 mutable Argument m_argument ;
414 mutable Argument m_argF ;
415
416 };
417
418 } // end of namespace GaudiMathImplementation
419 } // end of namespace Genfun
420
421 // ============================================================================
422 // The END
423 // ============================================================================
424 #endif // GAUDIMATH_NUMERICALDEFINITEINTEGRAL_H
425 // ============================================================================
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_epsabs
double m_epsabs
Definition: NumericalDefiniteIntegral.h:404
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::hasAnalyticDerivative
virtual bool hasAnalyticDerivative() const
Does this function have an analytic derivative?
Definition: NumericalDefiniteIntegral.h:311
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::size
size_t size() const
Definition: NumericalDefiniteIntegral.h:336
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::category
GaudiMath::Integration::Category category() const
integration category
Definition: NumericalDefiniteIntegral.h:343
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_error
double m_error
Definition: NumericalDefiniteIntegral.h:408
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::_Workspace
Definition: NumericalDefiniteIntegral.h:74
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::ws
_Workspace * ws() const
Definition: NumericalDefiniteIntegral.h:364
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::_Workspace::ws
gsl_integration_workspace * ws
Definition: NumericalDefiniteIntegral.h:74
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_category
GaudiMath::Integration::Category m_category
Definition: NumericalDefiniteIntegral.h:398
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_epsrel
double m_epsrel
Definition: NumericalDefiniteIntegral.h:405
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_size
size_t m_size
Definition: NumericalDefiniteIntegral.h:410
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:331
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_b
double m_b
Definition: NumericalDefiniteIntegral.h:393
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_DIM
size_t m_DIM
Definition: NumericalDefiniteIntegral.h:389
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_ws
std::unique_ptr< _Workspace, gsl_ws_deleter > m_ws
Definition: NumericalDefiniteIntegral.h:411
GaudiMath::Integration::Infinity
Definition: Integration.h:20
GaudiMath::Integration::Adaptive
Definition: Integration.h:26
GaudiMath::Derivative
Genfun::GaudiMathImplementation::NumericalDerivative Derivative
Definition: GaudiMath.h:29
merge_files.sc
int sc
Definition: merge_files.py:167
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::gsl_ws_deleter
Definition: NumericalDefiniteIntegral.h:380
std::string
STL class.
gaudirun.type
string type
Definition: gaudirun.py:151
StatusCode::FAILURE
Definition: StatusCode.h:29
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_index
size_t m_index
Definition: NumericalDefiniteIntegral.h:390
merge_files.default
list default
Definition: merge_files.py:105
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::epsabs
double epsabs() const
absolute precision
Definition: NumericalDefiniteIntegral.h:326
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_points
Points m_points
Definition: NumericalDefiniteIntegral.h:401
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_rule
GaudiMath::Integration::KronrodRule m_rule
Definition: NumericalDefiniteIntegral.h:399
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
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_ia
bool m_ia
Definition: NumericalDefiniteIntegral.h:394
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_result
double m_result
Definition: NumericalDefiniteIntegral.h:407
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::error
double error() const
evaluate of previous error
Definition: NumericalDefiniteIntegral.h:333
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_pdata
std::unique_ptr< double[]> m_pdata
Definition: NumericalDefiniteIntegral.h:402
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:328
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_a
double m_a
Definition: NumericalDefiniteIntegral.h:392
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::gsl_ws_deleter::operator()
void operator()(_Workspace *p) const
Definition: NumericalDefiniteIntegral.h:381
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_type
GaudiMath::Integration::Type m_type
Definition: NumericalDefiniteIntegral.h:397
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::type
GaudiMath::Integration::Type type() const
integration type
Definition: NumericalDefiniteIntegral.h:340
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_function
std::unique_ptr< const AbsFunction > m_function
Definition: NumericalDefiniteIntegral.h:388
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::Points
std::vector< double > Points
typedef for vector of singular points
Definition: NumericalDefiniteIntegral.h:75
std::vector< double >
std::unique_ptr< const AbsFunction >
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::points
const Points & points() const
known singularities
Definition: NumericalDefiniteIntegral.h:324
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:414
GaudiMath::Integration::KronrodRule
KronrodRule
integration rule
Definition: Integration.h:34
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_ib
bool m_ib
Definition: NumericalDefiniteIntegral.h:395
Genfun
CLHEP.
Definition: IEqSolver.h:13
StatusCode.h
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::b
double b() const
Definition: NumericalDefiniteIntegral.h:322
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::m_argument
Argument m_argument
Definition: NumericalDefiniteIntegral.h:413
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:346
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral::a
double a() const
integration limit
Definition: NumericalDefiniteIntegral.h:321
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:71