| The Gaudi Framework v29r0 (ff2e7097)

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

- Class List
- Class Index
- Class Hierarchy
- Class Members

Classes | Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral Class Reference

The simple class for numerical integrations. More...

`#include <GaudiMath/NumericalIndefiniteIntegral.h>`

Inheritance diagram for Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral:
[legend]
Collaboration diagram for Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral:
[legend]

## Classes
struct | _Function
struct | _Workspace
struct | gsl_ws_deleter

## Public Types
typedef std::vector< double > | Points
| typedef for vector of singular points More...

## Public Member Functions
| NumericalIndefiniteIntegral (const AbsFunction &function, const size_t index, const double a, const GaudiMath::Integration::Limit limit=GaudiMath::Integration::VariableHighLimit, const GaudiMath::Integration::Type type=GaudiMath::Integration::Adaptive, const GaudiMath::Integration::KronrodRule rule=GaudiMath::Integration::Default, const double epsabs=1e-10, const double epsrel=1.e-7, const size_t size=1000)
| From CLHEP/GenericFunctions. More...
| NumericalIndefiniteIntegral (const AbsFunction &function, const size_t index, const double a, const Points &points, const GaudiMath::Integration::Limit limit=GaudiMath::Integration::VariableHighLimit, const double epsabs=1e-9, const double epsrel=1.e-6, const size_t size=1000)
| standard constructor More...
| NumericalIndefiniteIntegral (const AbsFunction &function, const size_t index, const GaudiMath::Integration::Limit limit=GaudiMath::Integration::VariableHighLimit, const double epsabs=1e-9, const double epsrel=1.e-6, const size_t size=1000)
| standard constructor The function, created with this constructor evaluates following indefinite integral: More...
| NumericalIndefiniteIntegral (const NumericalIndefiniteIntegral &)
| copy constructor More...
| ~NumericalIndefiniteIntegral () override=default
| destructor More...
unsigned int | dimensionality () const override
| dimensionality of the problem More...
double | operator() (double argument) const override
| Function value. More...
double | operator() (const Argument &argument) const override
| Function value. More...
bool | hasAnalyticDerivative () const override
| Does this function have an analytic derivative? More...
Genfun::Derivative | partial (unsigned int index) const override
| Derivatives. More...
const AbsFunction & | function () const
| accessor to the function itself More...
double | a () const
| integration limit More...
const Points & | points () const
| known singularities More...
double | epsabs () const
| absolute precision More...
double | epsrel () const
| relatiove precision More...
double | result () const
| previous result More...
double | error () const
| evaluate of previous error More...
size_t | size () const
GaudiMath::Integration::Limit | limit () const
| integration limit More...
GaudiMath::Integration::Type | type () const
| integration type More...
GaudiMath::Integration::Category | category () const
| integration category More...
GaudiMath::Integration::KronrodRule | rule () const
| integration rule More...

## Protected Member Functions
double | QAGI (_Function *fun) const
double | QAGP (_Function *fun) const
double | QNG (_Function *fun) const
double | QAG (_Function *fun) const
double | QAGS (_Function *fun) const
_Workspace * | allocate () const
| allocate the integration workspace More...
_Workspace * | ws () const
StatusCode | Exception (const std::string &message, const StatusCode &sc=StatusCode::FAILURE) const

## Private Member Functions
| NumericalIndefiniteIntegral ()
NumericalIndefiniteIntegral & | operator= (const NumericalIndefiniteIntegral &)

## Private Attributes
std::unique_ptr< const AbsFunction > | m_function
size_t | m_DIM
size_t | m_index
double | m_a
GaudiMath::Integration::Limit | m_limit
GaudiMath::Integration::Type | m_type
GaudiMath::Integration::Category | m_category
GaudiMath::Integration::KronrodRule | m_rule
Points | m_points
double | m_epsabs
double | m_epsrel
double | m_result = GSL_NEGINF
double | m_error = GSL_POSINF
size_t | m_size
std::unique_ptr< _Workspace, gsl_ws_deleter > | m_ws
Argument | m_argument

## Detailed Description

The simple class for numerical integrations.

It allows to evaluate following indefinite integrals:

\[ {\mathcal{F}}_i \left(x_1, \dots , x_{i-1}, x_i , x_{i+1}, \dots , x_n \right) = \int\limits_{a}^{x_i} f \left(x_1, \dots , x_{i-1}, \hat{x}_i , x_{i+1}, \dots , x_n \right) \, {\mathrm{d}} \hat{x}_i \]

\[ {\mathcal{F}}_i \left(x_1, \dots , x_{i-1}, x_i , x_{i+1}, \dots , x_n \right) = \int\limits_{x_i}^{a} f \left(x_1, \dots , x_{i-1}, \hat{x}_i , x_{i+1}, \dots , x_n \right) \, {\mathrm{d}} \hat{x}_i \]

\[ {\mathcal{F}}_i \left(x_1, \dots , x_{i-1}, x_i , x_{i+1}, \dots , x_n \right) = \int\limits_{-\infty}^{x_i} f \left(x_1, \dots , x_{i-1}, \hat{x}_i , x_{i+1}, \dots , x_n \right) \, {\mathrm{d}} \hat{x}_i \]

\[ {\mathcal{F}}_i \left(x_1, \dots , x_{i-1}, x_i , x_{i+1}, \dots , x_n \right) = \int\limits_{x_i}^{+\infty} f \left(x_1, \dots , x_{i-1}, \hat{x}_i , x_{i+1}, \dots , x_n \right) \, {\mathrm{d}} \hat{x}_i \]

Author
  Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@i.nosp@m.tep..nosp@m.ru

Date
  2003-08-31

Definition at line 82 of file NumericalIndefiniteIntegral.h.

## Member Typedef Documentation

typedef std::vector<double> Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::Points

typedef for vector of singular points

Definition at line 88 of file NumericalIndefiniteIntegral.h.

## Constructor & Destructor Documentation

Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::NumericalIndefiniteIntegral | ( | const AbsFunction & | function,
|  | const size_t | index,
|  | const double | a,
|  | const GaudiMath::Integration::Limit | limit = `GaudiMath::Integration::VariableHighLimit`,
|  | const GaudiMath::Integration::Type | type = `GaudiMath::Integration::Adaptive`,
|  | const GaudiMath::Integration::KronrodRule | rule = `GaudiMath::Integration::Default`,
|  | const double | epsabs = `1e-10`,
|  | const double | epsrel = `1.e-7`,
|  | const size_t | size = `1000`
| ) |  |

From CLHEP/GenericFunctions.

Standard constructor.

Standard constructor The function, created with this constructor evaluates following indefinite integral:

\[ {\mathcal{F}}_i \left(x_1, \dots , x_{i-1}, x_i , x_{i+1}, \dots , x_n \right) = \int\limits_{a}^{x_i} f \left(x_1, \dots , x_{i-1}, \hat{x}_i , x_{i+1}, \dots , x_n \right) \, {\mathrm{d}} \hat{x}_i \]

for value of `limit` = `VariableHighLimit` and the integral

\[ {\mathcal{F}}_i \left(x_1, \dots , x_{i-1}, x_i , x_{i+1}, \dots , x_n \right) = \int\limits_{x_i}^{a} f \left(x_1, \dots , x_{i-1}, \hat{x}_i , x_{i+1}, \dots , x_n \right) \, {\mathrm{d}} \hat{x}_i \]

for value of `limit` = `VariableLowLimit`

If function contains singularities, the `type` = `Type::AdaptiveSingular` need to be used

For faster integration of smooth function non-adaptive integration can be used: `type` = `Type::NonAdaptive` need to be used

For adaptive integration one can specify the order of Gauss-Kronrad integration rule `rule` = `KronrodRule::Gauss15` The higher-order rules give better accuracy for smooth functions, while lower-order rules save the time when the function contains local difficulties, such as discontinuites.

- The GSL routine `gsl_integration_qng` is used for `type` = `Type:NonAdaptive` :
- The GSL routine `gsl_integration_qag` is used for `type` = `Type:Adaptive` :
- The GSL routine `gsl_integration_qags` is used for `type` = `Type:AdaptiveSingular` :

Parameters

  function | the base function
  index | the variable index
  a | integration limit
  limit | flag to distinguisch low variable limit from high variable limit
  type | the integration type (adaptive, non-adaptive or adaptive for singular functions
  key | Gauss-Kronrad integration rule
  epsabs | absolute precision for integration
  epsrel | relative precision for integration
  lim | bisection limit
  function | the base function
  index | the variable index
  a | integration limit
  limit | flag to distinguisch low variable limit from high variable limit
  type | the integration type (adaptive, non-adaptive or adaptive for singular functions
  key | Gauss-Kronrad integration rule
  epsabs | absolute precision for integration
  epsrel | relative precision for integration
  lim | bisection limit

Definition at line 74 of file NumericalIndefiniteIntegral.cpp.

80 : AbsFunction()
81 , m_function( function.clone() )
82 , m_DIM( function.dimensionality() )
83 , m_index( index )
84 , m_a( a )
85 , m_limit( limit )
86 , m_type( type )
87 , m_category( GaudiMath::Integration::Finite )
88 , m_rule( rule )
89 //
90 , m_epsabs( epsabs )
91 , m_epsrel( epsrel )
92 //
93 , m_size( size )
94 , m_argument( function.dimensionality() )
95 {
96 if ( GaudiMath::Integration::Fixed == m_rule ) {
97 m_rule = GaudiMath::Integration::Default;
98 }
99 if ( m_index >= m_DIM ) {
100 Exception( "::constructor: invalid variable index" );
101 }
102 }
GaudiMath::Integration::Finite
Definition: Integration.h:26
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::epsrel
double epsrel() const
relatiove precision
Definition: NumericalIndefiniteIntegral.h:288
GaudiMath::Integration::Fixed
Definition: Integration.h:29
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::Exception
StatusCode Exception(const std::string &message, const StatusCode &sc=StatusCode::FAILURE) const
Definition: NumericalIndefiniteIntegral.cpp:202
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
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
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::m_epsrel
double m_epsrel
Definition: NumericalIndefiniteIntegral.h:357
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::epsabs
double epsabs() const
absolute precision
Definition: NumericalIndefiniteIntegral.h:286
GaudiMath::Integration::Default
Definition: Integration.h:36
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::dimensionality
unsigned int dimensionality() const override
dimensionality of the problem
Definition: NumericalIndefiniteIntegral.h:265
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
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
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_rule
GaudiMath::Integration::KronrodRule m_rule
Definition: NumericalIndefiniteIntegral.h:352

Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::NumericalIndefiniteIntegral | ( | const AbsFunction & | function,
|  | const size_t | index,
|  | const double | a,
|  | const Points & | points,
|  | const GaudiMath::Integration::Limit | limit = `GaudiMath::Integration::VariableHighLimit`,
|  | const double | epsabs = `1e-9`,
|  | const double | epsrel = `1.e-6`,
|  | const size_t | size = `1000`
| ) |  |

standard constructor

The function, created with this constructor evaluates following indefinite integral:

\[ {\mathcal{F}}_i \left(x_1, \dots , x_{i-1}, x_i , x_{i+1}, \dots , x_n \right) = \int\limits_{a}^{x_i} f \left(x_1, \dots , x_{i-1}, \hat{x}_i , x_{i+1}, \dots , x_n \right) \, {\mathrm{d}} \hat{x}_i \]

for value of `limit` = `VariableHighLimit` and the integral

\[ {\mathcal{F}}_i \left(x_1, \dots , x_{i-1}, x_i , x_{i+1}, \dots , x_n \right) = \int\limits_{x_i}^{a} f \left(x_1, \dots , x_{i-1}, \hat{x}_i , x_{i+1}, \dots , x_n \right) \, {\mathrm{d}} \hat{x}_i \]

for value of `limit` = `VariableLowLimit`

The integrand is assumed to have a known discontinuities

- The GSL routine `gsl_integration_qagp` is used for integration

Parameters

  function | the base function
  index | the variable index
  a | integration limit
  limit | flag to distinguisch low variable limit from high variable limit
  points | list of known function singularities
  epsabs | absolute precision for integration
  epsrel | relative precision for integration
  function | the base function
  index | the variable index
  a | integration limit
  limit | flag to distinguisch low variable limit from high variable limit
  points | list of known function singularities
  epsabs | absolute precision for integration
  epsrel | relative precision for integration

Definition at line 115 of file NumericalIndefiniteIntegral.cpp.

120 : AbsFunction()
121 , m_function( function.clone() )
122 , m_DIM( function.dimensionality() )
123 , m_index( index )
124 , m_a( a )
125 , m_limit( limit )
126 , m_type( GaudiMath::Integration::Other )
127 , m_category( GaudiMath::Integration::Singular )
128 , m_rule( GaudiMath::Integration::Fixed )
129 , m_points( points )
130 , m_epsabs( epsabs )
131 , m_epsrel( epsrel )
132 //
133 , m_size( size )
134 , m_argument( function.dimensionality() )
135 {
136 if ( m_index >= m_DIM ) {
137 Exception( "::constructor: invalid variable index" );
138 }
139 m_points.push_back( a );
140 std::sort( m_points.begin(), m_points.end() );
141 m_points.erase( std::unique( m_points.begin(), m_points.end() ), m_points.end() );
142 }
GaudiMath::Integration::Other
Definition: Integration.h:24
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::epsrel
double epsrel() const
relatiove precision
Definition: NumericalIndefiniteIntegral.h:288
GaudiMath::Integration::Fixed
Definition: Integration.h:29
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::Exception
StatusCode Exception(const std::string &message, const StatusCode &sc=StatusCode::FAILURE) const
Definition: NumericalIndefiniteIntegral.cpp:202
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
std::vector::end
T end(T...args)
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::Integration::Singular
Definition: Integration.h:26
std::unique
T unique(T...args)
std::vector::push_back
T push_back(T...args)
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
std::vector::erase
T erase(T...args)
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_epsrel
double m_epsrel
Definition: NumericalIndefiniteIntegral.h:357
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::epsabs
double epsabs() const
absolute precision
Definition: NumericalIndefiniteIntegral.h:286
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::dimensionality
unsigned int dimensionality() const override
dimensionality of the problem
Definition: NumericalIndefiniteIntegral.h:265
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_function
std::unique_ptr< const AbsFunction > m_function
Definition: NumericalIndefiniteIntegral.h:343
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::a
double a() const
integration limit
Definition: NumericalIndefiniteIntegral.h:282
std::vector::begin
T begin(T...args)
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
std::sort
T sort(T...args)
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_rule
GaudiMath::Integration::KronrodRule m_rule
Definition: NumericalIndefiniteIntegral.h:352
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::points
const Points & points() const
known singularities
Definition: NumericalIndefiniteIntegral.h:284
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_points
Points m_points
Definition: NumericalIndefiniteIntegral.h:354

Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::NumericalIndefiniteIntegral | ( | const AbsFunction & | function,
|  | const size_t | index,
|  | const GaudiMath::Integration::Limit | limit = `GaudiMath::Integration::VariableHighLimit`,
|  | const double | epsabs = `1e-9`,
|  | const double | epsrel = `1.e-6`,
|  | const size_t | size = `1000`
| ) |  |

standard constructor The function, created with this constructor evaluates following indefinite integral:

standard constructor the integral limt is assumed to be infinity

\[ {\mathcal{F}}_i \left(x_1, \dots , x_{i-1}, x_i , x_{i+1}, \dots , x_n \right) = \int\limits_{-\infty}^{x_i} f \left(x_1, \dots , x_{i-1}, \hat{x}_i , x_{i+1}, \dots , x_n \right) \, {\mathrm{d}} \hat{x}_i \]

for value of `limit` = `VariableHighLimit` and the integral

\[ {\mathcal{F}}_i \left(x_1, \dots , x_{i-1}, x_i , x_{i+1}, \dots , x_n \right) = \int\limits_{x_i}^{+\infty} f \left(x_1, \dots , x_{i-1}, \hat{x}_i , x_{i+1}, \dots , x_n \right) \, {\mathrm{d}} \hat{x}_i \]

for value of `limit` = `VariableLowLimit`

- The GSL routines `gsl_integration_qagil` and `gsl_integration_qagiu` are used for adapive integration

Parameters

  function | the base function
  index | the variable index
  limit | flag to distinguisch low variable limit from high variable limit
  singularities | list of known function singularities
  function | the base function
  index | the variable index
  limit | flag to distinguisch low variable limit from high variable limit

Definition at line 153 of file NumericalIndefiniteIntegral.cpp.

157 : AbsFunction()
158 , m_function( function.clone() )
159 , m_DIM( function.dimensionality() )
160 , m_index( index )
161 , m_a( GSL_NEGINF ) // should not be used!
162 , m_limit( limit )
163 , m_type( GaudiMath::Integration::Other )
164 , m_category( GaudiMath::Integration::Infinite )
165 , m_rule( GaudiMath::Integration::Fixed )
166 , m_epsabs( epsabs )
167 , m_epsrel( epsrel )
168 , m_size( size )
169 , m_argument( function.dimensionality() )
170 {
171 if ( m_index >= m_DIM ) {
172 Exception( "::constructor: invalid variable index" );
173 }
174 }
GaudiMath::Integration::Other
Definition: Integration.h:24
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::epsrel
double epsrel() const
relatiove precision
Definition: NumericalIndefiniteIntegral.h:288
GaudiMath::Integration::Fixed
Definition: Integration.h:29
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::Exception
StatusCode Exception(const std::string &message, const StatusCode &sc=StatusCode::FAILURE) const
Definition: NumericalIndefiniteIntegral.cpp:202
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
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
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
GaudiMath::Integration::Infinite
Definition: Integration.h:26
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_epsrel
double m_epsrel
Definition: NumericalIndefiniteIntegral.h:357
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::epsabs
double epsabs() const
absolute precision
Definition: NumericalIndefiniteIntegral.h:286
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::dimensionality
unsigned int dimensionality() const override
dimensionality of the problem
Definition: NumericalIndefiniteIntegral.h:265
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_function
std::unique_ptr< const AbsFunction > m_function
Definition: NumericalIndefiniteIntegral.h:343
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
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_rule
GaudiMath::Integration::KronrodRule m_rule
Definition: NumericalIndefiniteIntegral.h:352

Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::NumericalIndefiniteIntegral | ( | const NumericalIndefiniteIntegral & | right | ) |

copy constructor

Definition at line 180 of file NumericalIndefiniteIntegral.cpp.

181 : AbsFunction()
182 , m_function( right.m_function->clone() )
183 , m_DIM( right.m_DIM )
184 , m_index( right.m_index )
185 , m_a( right.m_a )
186 , m_limit( right.m_limit )
187 , m_type( right.m_type )
188 , m_category( right.m_category )
189 , m_rule( right.m_rule )
190 , m_points( right.m_points )
191 , m_epsabs( right.m_epsabs )
192 , m_epsrel( right.m_epsrel )
193 , m_size( right.m_size )
194 , m_argument( right.m_argument )
195 {
196 }
std::right
T right(T...args)
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
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::m_epsrel
double m_epsrel
Definition: NumericalIndefiniteIntegral.h:357
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::m_function
std::unique_ptr< const AbsFunction > m_function
Definition: NumericalIndefiniteIntegral.h:343
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
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_rule
GaudiMath::Integration::KronrodRule m_rule
Definition: NumericalIndefiniteIntegral.h:352
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_points
Points m_points
Definition: NumericalIndefiniteIntegral.h:354

Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::~NumericalIndefiniteIntegral | ( |  | ) |
| override default

destructor

Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::NumericalIndefiniteIntegral | ( |  | ) |
| private

## Member Function Documentation

double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::a | ( |  | ) | const
| inline

integration limit

Definition at line 282 of file NumericalIndefiniteIntegral.h.

282 { return m_a; }
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_a
double m_a
Definition: NumericalIndefiniteIntegral.h:347

NumericalIndefiniteIntegral::_Workspace * Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::allocate | ( |  | ) | const
| protected

allocate the integration workspace

Definition at line 303 of file NumericalIndefiniteIntegral.cpp.

304 {
305 if ( !m_ws ) {
306 m_ws.reset( new _Workspace() );
307 m_ws->ws = gsl_integration_workspace_alloc( size() );
308 if ( !m_ws->ws ) {
309 Exception( "allocate()::invalid workspace" );
310 };
311 }
312 return m_ws.get();
313 }
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::Exception
StatusCode Exception(const std::string &message, const StatusCode &sc=StatusCode::FAILURE) const
Definition: NumericalIndefiniteIntegral.cpp:202
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::size
size_t size() const
Definition: NumericalIndefiniteIntegral.h:296
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_ws
std::unique_ptr< _Workspace, gsl_ws_deleter > m_ws
Definition: NumericalIndefiniteIntegral.h:363

GaudiMath::Integration::Category Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::category | ( |  | ) | const
| inline

integration category

Definition at line 303 of file NumericalIndefiniteIntegral.h.

303 { return m_category; }
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_category
GaudiMath::Integration::Category m_category
Definition: NumericalIndefiniteIntegral.h:351

unsigned int Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::dimensionality | ( |  | ) | const
| inline override

dimensionality of the problem

Definition at line 265 of file NumericalIndefiniteIntegral.h.

265 { return m_DIM; }
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_DIM
size_t m_DIM
Definition: NumericalIndefiniteIntegral.h:344

double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::epsabs | ( |  | ) | const
| inline

absolute precision

Definition at line 286 of file NumericalIndefiniteIntegral.h.

286 { return m_epsabs; }
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_epsabs
double m_epsabs
Definition: NumericalIndefiniteIntegral.h:356

double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::epsrel | ( |  | ) | const
| inline

relatiove precision

Definition at line 288 of file NumericalIndefiniteIntegral.h.

288 { return m_epsrel; }
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_epsrel
double m_epsrel
Definition: NumericalIndefiniteIntegral.h:357

double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::error | ( |  | ) | const
| inline

evaluate of previous error

Definition at line 293 of file NumericalIndefiniteIntegral.h.

293 { return m_error; }
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_error
double m_error
Definition: NumericalIndefiniteIntegral.h:360

StatusCode Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::Exception | ( | const std::string & | message,
|  | const StatusCode & | sc = `StatusCode::FAILURE`
| ) |  | const
| protected

Definition at line 202 of file NumericalIndefiniteIntegral.cpp.

203 {
204 throw GaudiException( "NumericalIndefiniteIntegral::" + message, "*GaudiMath*", sc );
205 return sc;
206 }
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:22

const AbsFunction& Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::function | ( |  | ) | const
| inline

accessor to the function itself

Definition at line 280 of file NumericalIndefiniteIntegral.h.

280 { return *m_function; }
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_function
std::unique_ptr< const AbsFunction > m_function
Definition: NumericalIndefiniteIntegral.h:343

bool Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::hasAnalyticDerivative | ( |  | ) | const
| inline override

Does this function have an analytic derivative?

Definition at line 273 of file NumericalIndefiniteIntegral.h.

273 { return true; }

GaudiMath::Integration::Limit Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::limit | ( |  | ) | const
| inline

integration limit

Definition at line 299 of file NumericalIndefiniteIntegral.h.

299 { return m_limit; }
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_limit
GaudiMath::Integration::Limit m_limit
Definition: NumericalIndefiniteIntegral.h:349

double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::operator() | ( | double | argument | ) | const
| override

Function value.

evaluate the function

Definition at line 212 of file NumericalIndefiniteIntegral.cpp.

213 {
214 // reset the result and the error
215 m_result = GSL_NEGINF;
216 m_error = GSL_POSINF;
217
218 // check the argument
219 if ( 1 != m_DIM ) {
220 Exception( "operator(): invalid argument size " );
221 };
222
223 m_argument[0] = argument;
224 return ( *this )( m_argument );
225 }
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_error
double m_error
Definition: NumericalIndefiniteIntegral.h:360
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::Exception
StatusCode Exception(const std::string &message, const StatusCode &sc=StatusCode::FAILURE) const
Definition: NumericalIndefiniteIntegral.cpp:202
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_DIM
size_t m_DIM
Definition: NumericalIndefiniteIntegral.h:344
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_argument
Argument m_argument
Definition: NumericalIndefiniteIntegral.h:365
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_result
double m_result
Definition: NumericalIndefiniteIntegral.h:359

double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::operator() | ( | const Argument & | argument | ) | const
| override

Function value.

evaluate the function

Definition at line 250 of file NumericalIndefiniteIntegral.cpp.

251 {
252 // reset the result and the error
253 m_result = GSL_NEGINF;
254 m_error = GSL_POSINF;
255
256 // check the argument
257 if ( argument.dimension() != m_DIM ) {
258 Exception( "operator(): invalid argument size " );
259 };
260
261 // copy the argument
262 for ( size_t i = 0; i < m_DIM; ++i ) {
263 m_argument[i] = argument[i];
264 }
265
266 // create the helper object
267 GSL_Helper helper( *m_function, m_argument, m_index );
268
269 // use GSL to evaluate the numerical derivative
270 gsl_function F;
271 F.function = &GSL_Adaptor;
272 F.params = &helper;
273 _Function F1;
274 F1.fn = &F;
275
276 switch ( category() ) {
277 case GaudiMath::Integration::Infinite:
278 return QAGI( &F1 );
279 case GaudiMath::Integration::Singular:
280 return QAGP( &F1 );
281 case GaudiMath::Integration::Finite:
282 switch ( type() ) {
283 case GaudiMath::Integration::NonAdaptive:
284 return QNG( &F1 );
285 case GaudiMath::Integration::Adaptive:
286 return QAG( &F1 );
287 case GaudiMath::Integration::AdaptiveSingular:
288 return QAGS( &F1 );
289 default:
290 Exception( "::operator(): invalid type " );
291 }
292 break;
293 default:
294 Exception( "::operator(): invalid category " );
295 }
296 return 0;
297 }
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_error
double m_error
Definition: NumericalIndefiniteIntegral.h:360
GaudiMath::Integration::Finite
Definition: Integration.h:26
GaudiMath::Integration::NonAdaptive
Definition: Integration.h:24
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::Exception
StatusCode Exception(const std::string &message, const StatusCode &sc=StatusCode::FAILURE) const
Definition: NumericalIndefiniteIntegral.cpp:202
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::QAGI
double QAGI(_Function *fun) const
Definition: NumericalIndefiniteIntegral.cpp:319
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_index
size_t m_index
Definition: NumericalIndefiniteIntegral.h:345
GaudiMath::Integration::Adaptive
Definition: Integration.h:24
GaudiMath::Integration::Singular
Definition: Integration.h:26
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::category
GaudiMath::Integration::Category category() const
integration category
Definition: NumericalIndefiniteIntegral.h:303
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::QAGS
double QAGS(_Function *fun) const
Definition: NumericalIndefiniteIntegral.cpp:488
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_DIM
size_t m_DIM
Definition: NumericalIndefiniteIntegral.h:344
GaudiMath::Integration::Infinite
Definition: Integration.h:26
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::QNG
double QNG(_Function *fun) const
Definition: NumericalIndefiniteIntegral.cpp:411
Genfun::GaudiMathImplementation::GSL_Adaptor
double GSL_Adaptor(double x, void *params)
Definition: Helpers.cpp:31
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::QAG
double QAG(_Function *fun) const
Definition: NumericalIndefiniteIntegral.cpp:448
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
GaudiMath::Integration::AdaptiveSingular
Definition: Integration.h:24
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_argument
Argument m_argument
Definition: NumericalIndefiniteIntegral.h:365
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_result
double m_result
Definition: NumericalIndefiniteIntegral.h:359
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::QAGP
double QAGP(_Function *fun) const
Definition: NumericalIndefiniteIntegral.cpp:354

NumericalIndefiniteIntegral& Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::operator= | ( | const NumericalIndefiniteIntegral & |  | ) |
| private

Genfun::Derivative Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::partial | ( | unsigned int | index | ) | const
| override

Derivatives.

Definition at line 231 of file NumericalIndefiniteIntegral.cpp.

232 {
233 if ( idx >= m_DIM ) {
234 Exception( "::partial(i): invalid variable index " );
235 };
236 if ( idx != m_index ) {
237 const AbsFunction& aux = NumericalDerivative( *this, idx );
238 return Genfun::FunctionNoop( &aux );
239 } else if ( GaudiMath::Integration::VariableLowLimit == limit() ) {
240 const AbsFunction& aux = -1 * function();
241 return Genfun::FunctionNoop( &aux );
242 }
243 const AbsFunction& aux = function();
244 return Genfun::FunctionNoop( &aux );
245 }
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::Exception
StatusCode Exception(const std::string &message, const StatusCode &sc=StatusCode::FAILURE) const
Definition: NumericalIndefiniteIntegral.cpp:202
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_index
size_t m_index
Definition: NumericalIndefiniteIntegral.h:345
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::limit
GaudiMath::Integration::Limit limit() const
integration limit
Definition: NumericalIndefiniteIntegral.h:299
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_DIM
size_t m_DIM
Definition: NumericalIndefiniteIntegral.h:344
GaudiMath::Integration::VariableLowLimit
Definition: Integration.h:22

const Points& Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::points | ( |  | ) | const
| inline

known singularities

Definition at line 284 of file NumericalIndefiniteIntegral.h.

284 { return m_points; }
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_points
Points m_points
Definition: NumericalIndefiniteIntegral.h:354

double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::QAG | ( | _Function * | fun | ) | const
| protected

Definition at line 448 of file NumericalIndefiniteIntegral.cpp.

449 {
450 if ( !F ) {
451 Exception( "QAG::invalid function" );
452 }
453
454 const double x = m_argument[m_index];
455 if ( m_a == x ) {
456 m_result = 0;
457 m_error = 0; // EXACT !
458 return m_result;
459 }
460
461 // allocate workspace
462 allocate();
463
464 // integration limits
465 const auto limits = std::minmax( m_a, x );
466
467 int ierror = gsl_integration_qag( F->fn, limits.first, limits.second, m_epsabs, m_epsrel, size(), (int)rule(),
468 ws()->ws, &m_result, &m_error );
469
470 if ( ierror ) {
471 gsl_error( "NumericalIndefiniteIntegral::QAG ", __FILE__, __LINE__, ierror );
472 }
473
474 // sign
475 if ( GaudiMath::Integration::VariableHighLimit == limit() && x < m_a ) {
476 m_result *= -1;
477 } else if ( GaudiMath::Integration::VariableLowLimit == limit() && x > m_a ) {
478 m_result *= -1;
479 }
480
481 return m_result;
482 }
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_error
double m_error
Definition: NumericalIndefiniteIntegral.h:360
std::minmax
T minmax(T...args)
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::Exception
StatusCode Exception(const std::string &message, const StatusCode &sc=StatusCode::FAILURE) const
Definition: NumericalIndefiniteIntegral.cpp:202
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
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
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_epsabs
double m_epsabs
Definition: NumericalIndefiniteIntegral.h:356
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::rule
GaudiMath::Integration::KronrodRule rule() const
integration rule
Definition: NumericalIndefiniteIntegral.h:305
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::allocate
_Workspace * allocate() const
allocate the integration workspace
Definition: NumericalIndefiniteIntegral.cpp:303
GaudiMath::Integration::VariableHighLimit
Definition: Integration.h:22
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_epsrel
double m_epsrel
Definition: NumericalIndefiniteIntegral.h:357
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_argument
Argument m_argument
Definition: NumericalIndefiniteIntegral.h:365
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_result
double m_result
Definition: NumericalIndefiniteIntegral.h:359
GaudiMath::Integration::VariableLowLimit
Definition: Integration.h:22
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::ws
_Workspace * ws() const
Definition: NumericalIndefiniteIntegral.h:322

double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::QAGI | ( | _Function * | fun | ) | const
| protected

Definition at line 319 of file NumericalIndefiniteIntegral.cpp.

320 {
321 // check the argument
322 if ( !F ) {
323 Exception( "::QAGI: invalid function" );
324 }
325
326 const double x = m_argument[m_index];
327
328 // allocate workspace
329 allocate();
330
331 int ierror = 0;
332 switch ( limit() ) {
333 case GaudiMath::Integration::VariableLowLimit:
334 ierror = gsl_integration_qagiu( F->fn, x, m_epsabs, m_epsrel, size(), ws()->ws, &m_result, &m_error );
335 break;
336 case GaudiMath::Integration::VariableHighLimit:
337 ierror = gsl_integration_qagil( F->fn, x, m_epsabs, m_epsrel, size(), ws()->ws, &m_result, &m_error );
338 break;
339 default:
340 Exception( "::QAGI: invalid mode" );
341 };
342
343 if ( ierror ) {
344 gsl_error( "NumericalIndefiniteIntegral::QAGI", __FILE__, __LINE__, ierror );
345 }
346
347 return m_result;
348 }
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_error
double m_error
Definition: NumericalIndefiniteIntegral.h:360
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::Exception
StatusCode Exception(const std::string &message, const StatusCode &sc=StatusCode::FAILURE) const
Definition: NumericalIndefiniteIntegral.cpp:202
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_index
size_t m_index
Definition: NumericalIndefiniteIntegral.h:345
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
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_epsabs
double m_epsabs
Definition: NumericalIndefiniteIntegral.h:356
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::allocate
_Workspace * allocate() const
allocate the integration workspace
Definition: NumericalIndefiniteIntegral.cpp:303
GaudiMath::Integration::VariableHighLimit
Definition: Integration.h:22
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_epsrel
double m_epsrel
Definition: NumericalIndefiniteIntegral.h:357
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_argument
Argument m_argument
Definition: NumericalIndefiniteIntegral.h:365
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_result
double m_result
Definition: NumericalIndefiniteIntegral.h:359
GaudiMath::Integration::VariableLowLimit
Definition: Integration.h:22
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::ws
_Workspace * ws() const
Definition: NumericalIndefiniteIntegral.h:322

double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::QAGP | ( | _Function * | fun | ) | const
| protected

Definition at line 354 of file NumericalIndefiniteIntegral.cpp.

355 {
356 if ( !F ) {
357 Exception( "QAGP::invalid function" );
358 }
359
360 const double x = m_argument[m_index];
361 if ( m_a == x ) {
362 m_result = 0;
363 m_error = 0; // EXACT !
364 return m_result;
365 }
366
367 // no known singular points ?
368 if ( points().empty() ) {
369 return QAGS( F );
370 }
371
372 // integration limits
373 const auto limits = std::minmax( m_a, x );
374
375 // "active" singular points
376 auto lower = std::lower_bound( points().begin(), points().end(), limits.first );
377 auto upper = std::upper_bound( points().begin(), points().end(), limits.second );
378
379 Points pnts;
380 pnts.reserve( std::distance( lower, upper ) );
381 std::copy( lower, upper, std::back_inserter( pnts ) );
382 if ( *lower != limits.first ) {
383 pnts.insert( pnts.begin(), limits.first );
384 }
385 if ( *upper != limits.second ) {
386 pnts.insert( pnts.end(), limits.second );
387 }
388
389 // use GSL
390 int ierror = gsl_integration_qagp( F->fn, pnts.data(), pnts.size(), m_epsabs, m_epsrel, size(), ws()->ws,
391 &m_result, &m_error );
392
393 if ( ierror ) {
394 gsl_error( "NumericalIndefiniteIntegral::QAGI ", __FILE__, __LINE__, ierror );
395 }
396
397 // sign
398 if ( GaudiMath::Integration::VariableHighLimit == limit() && x < m_a ) {
399 m_result *= -1;
400 } else if ( GaudiMath::Integration::VariableLowLimit == limit() && x > m_a ) {
401 m_result *= -1;
402 }
403
404 return m_result;
405 }
std::copy
T copy(T...args)
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_error
double m_error
Definition: NumericalIndefiniteIntegral.h:360
std::distance
T distance(T...args)
std::minmax
T minmax(T...args)
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::Exception
StatusCode Exception(const std::string &message, const StatusCode &sc=StatusCode::FAILURE) const
Definition: NumericalIndefiniteIntegral.cpp:202
std::upper_bound
T upper_bound(T...args)
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
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
std::lower_bound
T lower_bound(T...args)
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::_Workspace::ws
gsl_integration_workspace * ws
Definition: NumericalIndefiniteIntegral.h:86
begin
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:58
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_epsabs
double m_epsabs
Definition: NumericalIndefiniteIntegral.h:356
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::QAGS
double QAGS(_Function *fun) const
Definition: NumericalIndefiniteIntegral.cpp:488
GaudiMath::Integration::VariableHighLimit
Definition: Integration.h:22
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_epsrel
double m_epsrel
Definition: NumericalIndefiniteIntegral.h:357
end
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:64
std::back_inserter
T back_inserter(T...args)
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_argument
Argument m_argument
Definition: NumericalIndefiniteIntegral.h:365
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::Points
std::vector< double > Points
typedef for vector of singular points
Definition: NumericalIndefiniteIntegral.h:88
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_result
double m_result
Definition: NumericalIndefiniteIntegral.h:359
GaudiMath::Integration::VariableLowLimit
Definition: Integration.h:22
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::points
const Points & points() const
known singularities
Definition: NumericalIndefiniteIntegral.h:284
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::ws
_Workspace * ws() const
Definition: NumericalIndefiniteIntegral.h:322
std::vector::reserve
T reserve(T...args)

double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::QAGS | ( | _Function * | fun | ) | const
| protected

Definition at line 488 of file NumericalIndefiniteIntegral.cpp.

489 {
490 if ( !F ) {
491 Exception( "QAG::invalid function" );
492 }
493
494 const double x = m_argument[m_index];
495 if ( m_a == x ) {
496 m_result = 0;
497 m_error = 0; // EXACT !
498 return m_result;
499 }
500
501 // allocate workspace
502 allocate();
503
504 // integration limits
505 const auto limits = std::minmax( m_a, x );
506
507 int ierror = gsl_integration_qags( F->fn, limits.first, limits.second, m_epsabs, m_epsrel, size(), ws()->ws,
508 &m_result, &m_error );
509
510 if ( ierror ) {
511 gsl_error( "NumericalIndefiniteIntegral::QAGS ", __FILE__, __LINE__, ierror );
512 }
513
514 // sign
515 if ( GaudiMath::Integration::VariableHighLimit == limit() && x < m_a ) {
516 m_result *= -1;
517 } else if ( GaudiMath::Integration::VariableLowLimit == limit() && x > m_a ) {
518 m_result *= -1;
519 }
520
521 return m_result;
522 }
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_error
double m_error
Definition: NumericalIndefiniteIntegral.h:360
std::minmax
T minmax(T...args)
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::Exception
StatusCode Exception(const std::string &message, const StatusCode &sc=StatusCode::FAILURE) const
Definition: NumericalIndefiniteIntegral.cpp:202
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
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
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_epsabs
double m_epsabs
Definition: NumericalIndefiniteIntegral.h:356
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::allocate
_Workspace * allocate() const
allocate the integration workspace
Definition: NumericalIndefiniteIntegral.cpp:303
GaudiMath::Integration::VariableHighLimit
Definition: Integration.h:22
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_epsrel
double m_epsrel
Definition: NumericalIndefiniteIntegral.h:357
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_argument
Argument m_argument
Definition: NumericalIndefiniteIntegral.h:365
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_result
double m_result
Definition: NumericalIndefiniteIntegral.h:359
GaudiMath::Integration::VariableLowLimit
Definition: Integration.h:22
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::ws
_Workspace * ws() const
Definition: NumericalIndefiniteIntegral.h:322

double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::QNG | ( | _Function * | fun | ) | const
| protected

Definition at line 411 of file NumericalIndefiniteIntegral.cpp.

412 {
413 if ( !F ) {
414 Exception( "QNG::invalid function" );
415 }
416
417 const double x = m_argument[m_index];
418 if ( m_a == x ) {
419 m_result = 0;
420 m_error = 0; // EXACT !
421 return m_result;
422 }
423
424 // integration limits
425 const double a = std::min( m_a, x );
426 const double b = std::max( m_a, x );
427
428 size_t neval = 0;
429 int ierror = gsl_integration_qng( F->fn, a, b, m_epsabs, m_epsrel, &m_result, &m_error, &neval );
430
431 if ( ierror ) {
432 gsl_error( "NumericalIndefiniteIntegral::QNG ", __FILE__, __LINE__, ierror );
433 }
434
435 // sign
436 if ( GaudiMath::Integration::VariableHighLimit == limit() && x < m_a ) {
437 m_result *= -1;
438 } else if ( GaudiMath::Integration::VariableLowLimit == limit() && x > m_a ) {
439 m_result *= -1;
440 }
441
442 return m_result;
443 }
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_error
double m_error
Definition: NumericalIndefiniteIntegral.h:360
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::Exception
StatusCode Exception(const std::string &message, const StatusCode &sc=StatusCode::FAILURE) const
Definition: NumericalIndefiniteIntegral.cpp:202
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
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::limit
GaudiMath::Integration::Limit limit() const
integration limit
Definition: NumericalIndefiniteIntegral.h:299
std::min
T min(T...args)
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_epsabs
double m_epsabs
Definition: NumericalIndefiniteIntegral.h:356
GaudiMath::Integration::VariableHighLimit
Definition: Integration.h:22
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_epsrel
double m_epsrel
Definition: NumericalIndefiniteIntegral.h:357
std::max
T max(T...args)
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::a
double a() const
integration limit
Definition: NumericalIndefiniteIntegral.h:282
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_argument
Argument m_argument
Definition: NumericalIndefiniteIntegral.h:365
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_result
double m_result
Definition: NumericalIndefiniteIntegral.h:359
GaudiMath::Integration::VariableLowLimit
Definition: Integration.h:22

double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::result | ( |  | ) | const
| inline

previous result

Definition at line 291 of file NumericalIndefiniteIntegral.h.

291 { return m_result; }
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_result
double m_result
Definition: NumericalIndefiniteIntegral.h:359

GaudiMath::Integration::KronrodRule Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::rule | ( |  | ) | const
| inline

integration rule

Definition at line 305 of file NumericalIndefiniteIntegral.h.

305 { return m_rule; }
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_rule
GaudiMath::Integration::KronrodRule m_rule
Definition: NumericalIndefiniteIntegral.h:352

size_t Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::size | ( |  | ) | const
| inline

Definition at line 296 of file NumericalIndefiniteIntegral.h.

296 { return m_size; }
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_size
size_t m_size
Definition: NumericalIndefiniteIntegral.h:362

GaudiMath::Integration::Type Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::type | ( |  | ) | const
| inline

integration type

Definition at line 301 of file NumericalIndefiniteIntegral.h.

301 { return m_type; }
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_type
GaudiMath::Integration::Type m_type
Definition: NumericalIndefiniteIntegral.h:350

_Workspace* Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::ws | ( |  | ) | const
| inline protected

Definition at line 322 of file NumericalIndefiniteIntegral.h.

322 { return m_ws.get(); }
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_ws
std::unique_ptr< _Workspace, gsl_ws_deleter > m_ws
Definition: NumericalIndefiniteIntegral.h:363

## Member Data Documentation

double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_a
| private

Definition at line 347 of file NumericalIndefiniteIntegral.h.

Argument Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_argument
| mutable private

Definition at line 365 of file NumericalIndefiniteIntegral.h.

GaudiMath::Integration::Category Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_category
| private

Definition at line 351 of file NumericalIndefiniteIntegral.h.

size_t Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_DIM
| private

Definition at line 344 of file NumericalIndefiniteIntegral.h.

double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_epsabs
| private

Definition at line 356 of file NumericalIndefiniteIntegral.h.

double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_epsrel
| private

Definition at line 357 of file NumericalIndefiniteIntegral.h.

double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_error = GSL_POSINF
| mutable private

Definition at line 360 of file NumericalIndefiniteIntegral.h.

std::unique_ptr<const AbsFunction> Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_function
| private

Definition at line 343 of file NumericalIndefiniteIntegral.h.

size_t Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_index
| private

Definition at line 345 of file NumericalIndefiniteIntegral.h.

GaudiMath::Integration::Limit Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_limit
| private

Definition at line 349 of file NumericalIndefiniteIntegral.h.

Points Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_points
| private

Definition at line 354 of file NumericalIndefiniteIntegral.h.

double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_result = GSL_NEGINF
| mutable private

Definition at line 359 of file NumericalIndefiniteIntegral.h.

GaudiMath::Integration::KronrodRule Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_rule
| private

Definition at line 352 of file NumericalIndefiniteIntegral.h.

size_t Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_size
| private

Definition at line 362 of file NumericalIndefiniteIntegral.h.

GaudiMath::Integration::Type Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_type
| private

Definition at line 350 of file NumericalIndefiniteIntegral.h.

std::unique_ptr<_Workspace, gsl_ws_deleter> Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_ws
| mutable private

Definition at line 363 of file NumericalIndefiniteIntegral.h.

The documentation for this class was generated from the following files:

- GaudiGSL/GaudiMath/NumericalIndefiniteIntegral.h
- GaudiGSL/src/Lib/NumericalIndefiniteIntegral.cpp