Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral Class Reference

The simple class for numerical integrations. More...

#include </scratch/z5/marcocle/GaudiDocs/lhcb-release/996/GAUDI/GAUDI_v26r4/InstallArea/x86_64-slc6-gcc48-opt/include/GaudiMath/NumericalIndefiniteIntegral.h>

Inheritance diagram for Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral:
Collaboration diagram for Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral:

Classes

struct  _Function
 
struct  _Workspace
 
struct  gsl_ws_deleter
 

Public Types

typedef std::vector< double > Points
 typedef for vector of singular points More...
 
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...
 
virtual ~NumericalIndefiniteIntegral ()=default
 destructor More...
 
virtual unsigned int dimensionality () const
 dimensionality of the problem More...
 
virtual double operator() (double argument) const
 Function value. More...
 
virtual double operator() (const Argument &argument) const
 Function value. More...
 
virtual bool hasAnalyticDerivative () const
 Does this function have an analytic derivative? More...
 
virtual Genfun::Derivative partial (unsigned int index) const
 Derivatives. More...
 
const AbsFunction & function () const
 accessor to the function itself More...
 
double a () const
 integration limit More...
 
const Pointspoints () 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...
 
 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...
 
virtual ~NumericalIndefiniteIntegral ()=default
 destructor More...
 
virtual unsigned int dimensionality () const
 dimensionality of the problem More...
 
virtual double operator() (double argument) const
 Function value. More...
 
virtual double operator() (const Argument &argument) const
 Function value. More...
 
virtual bool hasAnalyticDerivative () const
 Does this function have an analytic derivative? More...
 
virtual Genfun::Derivative partial (unsigned int index) const
 Derivatives. More...
 
const AbsFunction & function () const
 accessor to the function itself More...
 
double a () const
 integration limit More...
 
const Pointspoints () 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
 
_Workspaceallocate () const
 allocate the integration workspace More...
 
_Workspacews () const
 
StatusCode Exception (const std::string &message, const StatusCode &sc=StatusCode::FAILURE) const
 
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
 
_Workspaceallocate () const
 
_Workspacews () const
 
StatusCode Exception (const std::string &message, const StatusCode &sc=StatusCode::FAILURE) const
 

Private Member Functions

 NumericalIndefiniteIntegral ()
 
NumericalIndefiniteIntegraloperator= (const NumericalIndefiniteIntegral &)
 
 NumericalIndefiniteIntegral ()
 
NumericalIndefiniteIntegraloperator= (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
 
std::unique_ptr< double[]> m_pdata
 
double m_epsabs
 
double m_epsrel
 
double m_result
 
double m_error
 
size_t m_size
 
std::unique_ptr< _Workspace, gsl_ws_deleterm_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 75 of file NumericalIndefiniteIntegral.h.

Member Typedef Documentation

typedef for vector of singular points

Definition at line 79 of file NumericalIndefiniteIntegral.h.

typedef for vector of singular points

Definition at line 79 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.

from CLHEP/GenericFunctions

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
functionthe base function
indexthe variable index
aintegration limit
limitflag to distinguisch low variable limit from high variable limit
typethe integration type (adaptive, non-adaptive or adaptive for singular functions
keyGauss-Kronrad integration rule
epsabsabsolute precision for integration
epsrelrelative precision for integration
limbisection limit

Standard constructor

Parameters
functionthe base function
indexthe variable index
aintegration limit
limitflag to distinguisch low variable limit from high variable limit
typethe integration type (adaptive, non-adaptive or adaptive for singular functions
keyGauss-Kronrad integration rule
epsabsabsolute precision for integration
epsrelrelative precision for integration
limbisection limit

Definition at line 78 of file NumericalIndefiniteIntegral.cpp.

87  : AbsFunction ()
88  , m_function ( function.clone() )
89  , m_DIM ( function.dimensionality() )
90  , m_index ( index )
91  , m_a ( a )
92  , m_limit ( limit )
93  , m_type ( type )
95  , m_rule ( rule )
96  //
97  , m_points ( )
98  //
99  , m_epsabs ( epsabs )
100  , m_epsrel ( epsrel )
101  //
102  , m_result ( GSL_NEGINF )
103  , m_error ( GSL_POSINF )
104  //
105  , m_size ( size )
106  , m_argument ( function.dimensionality() )
107  {
110  if ( m_index >= m_DIM )
111  { Exception("::constructor: invalid variable index") ; }
112  }
StatusCode Exception(const std::string &message, const StatusCode &sc=StatusCode::FAILURE) const
GaudiMath::Integration::Limit limit() const
integration limit
virtual unsigned int dimensionality() const
dimensionality of the problem
GaudiMath::Integration::KronrodRule rule() const
integration rule
GaudiMath::Integration::Type type() const
integration type
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
functionthe base function
indexthe variable index
aintegration limit
limitflag to distinguisch low variable limit from high variable limit
pointslist of known function singularities
epsabsabsolute precision for integration
epsrelrelative precision for integration
functionthe base function
indexthe variable index
aintegration limit
limitflag to distinguisch low variable limit from high variable limit
pointslist of known function singularities
epsabsabsolute precision for integration
epsrelrelative precision for integration

Definition at line 126 of file NumericalIndefiniteIntegral.cpp.

134  : AbsFunction ()
135  , m_function ( function.clone() )
136  , m_DIM ( function.dimensionality() )
137  , m_index ( index )
138  , m_a ( a )
139  , m_limit ( limit )
143  , m_points ( points )
144  , m_epsabs ( epsabs )
145  , m_epsrel ( epsrel )
146  //
147  , m_result ( GSL_NEGINF )
148  , m_error ( GSL_POSINF )
149  //
150  , m_size ( size )
151  , m_argument ( function.dimensionality() )
152  {
153  if ( m_index >= m_DIM )
154  { Exception("::constructor: invalid variable index") ; }
155  m_pdata.reset( new double[ 2 + m_points.size() ] );
156  m_points.push_back( a ) ;
157  std::sort( m_points.begin() , m_points.end() ) ;
158  m_points.erase ( std::unique( m_points.begin () ,
159  m_points.end () ) , m_points.end() );
160  }
StatusCode Exception(const std::string &message, const StatusCode &sc=StatusCode::FAILURE) const
GaudiMath::Integration::Limit limit() const
integration limit
virtual unsigned int dimensionality() const
dimensionality of the problem
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
functionthe base function
indexthe variable index
limitflag to distinguisch low variable limit from high variable limit
singularitieslist of known function singularities
functionthe base function
indexthe variable index
limitflag to distinguisch low variable limit from high variable limit

Definition at line 172 of file NumericalIndefiniteIntegral.cpp.

178  : AbsFunction ()
179  , m_function ( function.clone() )
180  , m_DIM ( function.dimensionality() )
181  , m_index ( index )
182  , m_a ( GSL_NEGINF ) // should not be used!
183  , m_limit ( limit )
187  , m_points ( )
188  , m_epsabs ( epsabs )
189  , m_epsrel ( epsrel )
190  , m_result ( GSL_NEGINF )
191  , m_error ( GSL_POSINF )
192  , m_size ( size )
193  , m_argument ( function.dimensionality() )
194  {
195  if ( m_index >= m_DIM )
196  { Exception("::constructor: invalid variable index") ; }
197  }
StatusCode Exception(const std::string &message, const StatusCode &sc=StatusCode::FAILURE) const
GaudiMath::Integration::Limit limit() const
integration limit
virtual unsigned int dimensionality() const
dimensionality of the problem
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::NumericalIndefiniteIntegral ( const NumericalIndefiniteIntegral right)

copy constructor

Definition at line 205 of file NumericalIndefiniteIntegral.cpp.

206  : AbsFunction ()
207  , m_function ( right.m_function->clone() )
208  , m_DIM ( right.m_DIM )
209  , m_index ( right.m_index )
210  , m_a ( right.m_a )
211  , m_limit ( right.m_limit )
212  , m_type ( right.m_type )
213  , m_category ( right.m_category )
214  , m_rule ( right.m_rule )
215  , m_points ( right.m_points )
216  , m_epsabs ( right.m_epsabs )
217  , m_epsrel ( right.m_epsrel )
218  , m_result ( GSL_NEGINF )
219  , m_error ( GSL_POSINF )
220  , m_size ( right.m_size )
221  , m_argument ( right.m_argument )
222  {
223  m_pdata.reset( new double[ 2 + m_points.size() ] ) ;
224  }
virtual Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::~NumericalIndefiniteIntegral ( )
virtualdefault

destructor

Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::NumericalIndefiniteIntegral ( )
private
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 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
functionthe base function
indexthe variable index
aintegration limit
limitflag to distinguisch low variable limit from high variable limit
typethe integration type (adaptive, non-adaptive or adaptive for singular functions
keyGauss-Kronrad integration rule
epsabsabsolute precision for integration
epsrelrelative precision for integration
limbisection limit
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
functionthe base function
indexthe variable index
aintegration limit
limitflag to distinguisch low variable limit from high variable limit
pointslist of known function singularities
epsabsabsolute precision for integration
epsrelrelative precision for integration
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:

\[ {\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
functionthe base function
indexthe variable index
limitflag to distinguisch low variable limit from high variable limit
singularitieslist of known function singularities
Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::NumericalIndefiniteIntegral ( const NumericalIndefiniteIntegral )

copy constructor

virtual Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::~NumericalIndefiniteIntegral ( )
virtualdefault

destructor

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

Member Function Documentation

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

integration limit

Definition at line 295 of file NumericalIndefiniteIntegral.h.

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

integration limit

Definition at line 295 of file NumericalIndefiniteIntegral.h.

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

allocate the integration workspace

Definition at line 332 of file NumericalIndefiniteIntegral.cpp.

333  {
334  if ( !m_ws ) {
335  m_ws.reset( new _Workspace() );
336  m_ws->ws = gsl_integration_workspace_alloc( size () );
337  if ( !m_ws->ws ) { Exception ( "allocate()::invalid workspace" ) ; };
338  }
339  return m_ws.get() ;
340  }
StatusCode Exception(const std::string &message, const StatusCode &sc=StatusCode::FAILURE) const
_Workspace* Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::allocate ( ) const
protected
GaudiMath::Integration::Category Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::category ( ) const
inline

integration category

Definition at line 319 of file NumericalIndefiniteIntegral.h.

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

integration category

Definition at line 319 of file NumericalIndefiniteIntegral.h.

virtual unsigned int Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::dimensionality ( ) const
inlinevirtual

dimensionality of the problem

Definition at line 277 of file NumericalIndefiniteIntegral.h.

virtual unsigned int Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::dimensionality ( ) const
inlinevirtual

dimensionality of the problem

Definition at line 277 of file NumericalIndefiniteIntegral.h.

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

absolute precision

Definition at line 299 of file NumericalIndefiniteIntegral.h.

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

absolute precision

Definition at line 299 of file NumericalIndefiniteIntegral.h.

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

relatiove precision

Definition at line 301 of file NumericalIndefiniteIntegral.h.

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

relatiove precision

Definition at line 301 of file NumericalIndefiniteIntegral.h.

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

evaluate of previous error

Definition at line 306 of file NumericalIndefiniteIntegral.h.

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

evaluate of previous error

Definition at line 306 of file NumericalIndefiniteIntegral.h.

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

Definition at line 232 of file NumericalIndefiniteIntegral.cpp.

234  {
235  throw GaudiException( "NumericalIndefiniteIntegral::" + message ,
236  "*GaudiMath*" , sc ) ;
237  return sc ;
238  }
Define general base for Gaudi exception.
StatusCode Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::Exception ( const std::string &  message,
const StatusCode sc = StatusCode::FAILURE 
) const
protected
const AbsFunction& Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::function ( ) const
inline

accessor to the function itself

Definition at line 293 of file NumericalIndefiniteIntegral.h.

293 { return *m_function ; }
const AbsFunction& Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::function ( ) const
inline

accessor to the function itself

Definition at line 293 of file NumericalIndefiniteIntegral.h.

293 { return *m_function ; }
virtual bool Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::hasAnalyticDerivative ( ) const
inlinevirtual

Does this function have an analytic derivative?

Definition at line 285 of file NumericalIndefiniteIntegral.h.

285 { return true ;}
virtual bool Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::hasAnalyticDerivative ( ) const
inlinevirtual

Does this function have an analytic derivative?

Definition at line 285 of file NumericalIndefiniteIntegral.h.

285 { return true ;}
GaudiMath::Integration::Limit Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::limit ( ) const
inline

integration limit

Definition at line 313 of file NumericalIndefiniteIntegral.h.

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

integration limit

Definition at line 313 of file NumericalIndefiniteIntegral.h.

double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::operator() ( double  argument) const
virtual

Function value.

evaluate the function

Definition at line 245 of file NumericalIndefiniteIntegral.cpp.

246  {
247  // reset the result and the error
248  m_result = GSL_NEGINF ;
249  m_error = GSL_POSINF ;
250 
251  // check the argument
252  if( 1 != m_DIM ) { Exception ( "operator(): invalid argument size " ) ; };
253 
254  m_argument[0] = argument ;
255  return (*this) ( m_argument );
256  }
StatusCode Exception(const std::string &message, const StatusCode &sc=StatusCode::FAILURE) const
virtual double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::operator() ( double  argument) const
virtual

Function value.

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

Function value.

evaluate the function

Definition at line 285 of file NumericalIndefiniteIntegral.cpp.

286  {
287  // reset the result and the error
288  m_result = GSL_NEGINF ;
289  m_error = GSL_POSINF ;
290 
291  // check the argument
292  if( argument.dimension() != m_DIM )
293  { Exception ( "operator(): invalid argument size " ) ; };
294 
295  // copy the argument
296  {for( size_t i = 0 ; i < m_DIM ; ++i ){ m_argument[i] = argument[i];}}
297 
298  // create the helper object
299  GSL_Helper helper( *m_function , m_argument , m_index );
300 
301  // use GSL to evaluate the numerical derivative
302  gsl_function F ;
303  F.function = &GSL_Adaptor ;
304  F.params = &helper ;
305  _Function F1 ;
306  F1.fn = &F ;
307 
309  { return QAGI ( &F1 ) ; } // RETURN
311  { return QAGP ( &F1 ) ; } // RETURN
312  else if ( GaudiMath::Integration::Finite == category () )
314  { return QNG ( &F1 ) ; } // RETURN
315  else if ( GaudiMath::Integration::Adaptive == type () )
316  { return QAG ( &F1 ) ; } // RETURN
318  { return QAGS ( &F1 ) ; } // RETURN
319  else
320  { Exception ( "::operator(): invalid type " ); }
321  else
322  { Exception ( "::operator(): invalid category " ); }
323 
324  return 0 ;
325  }
StatusCode Exception(const std::string &message, const StatusCode &sc=StatusCode::FAILURE) const
GaudiMath::Integration::Category category() const
integration category
double GSL_Adaptor(double x, void *params)
Definition: Helpers.cpp:37
GaudiMath::Integration::Type type() const
integration type
list i
Definition: ana.py:128
virtual double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::operator() ( const Argument &  argument) const
virtual

Function value.

NumericalIndefiniteIntegral& Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::operator= ( const NumericalIndefiniteIntegral )
private
NumericalIndefiniteIntegral& Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::operator= ( const NumericalIndefiniteIntegral )
private
Genfun::Derivative Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::partial ( unsigned int  index) const
virtual

Derivatives.

Definition at line 263 of file NumericalIndefiniteIntegral.cpp.

264  {
265  if ( idx >= m_DIM )
266  { Exception ( "::partial(i): invalid variable index " ) ; };
267  if ( idx != m_index )
268  {
269  const AbsFunction& aux = NumericalDerivative( *this , idx ) ;
270  return Genfun::FunctionNoop( &aux ) ;
271  }
273  {
274  const AbsFunction& aux = -1 * function() ;
275  return Genfun::FunctionNoop( &aux ) ;
276  }
277  const AbsFunction& aux = function() ;
278  return Genfun::FunctionNoop( &aux ) ;
279  }
StatusCode Exception(const std::string &message, const StatusCode &sc=StatusCode::FAILURE) const
GaudiMath::Integration::Limit limit() const
integration limit
virtual Genfun::Derivative Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::partial ( unsigned int  index) const
virtual

Derivatives.

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

known singularities

Definition at line 297 of file NumericalIndefiniteIntegral.h.

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

known singularities

Definition at line 297 of file NumericalIndefiniteIntegral.h.

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

Definition at line 475 of file NumericalIndefiniteIntegral.cpp.

476  {
477  if( !F ) { Exception("QAG::invalid function") ; }
478 
479  const double x = m_argument[m_index] ;
480  if ( m_a == x )
481  {
482  m_result = 0 ;
483  m_error = 0 ; // EXACT !
484  return m_result ;
485  }
486 
487  // allocate workspace
488  allocate () ;
489 
490  // integration limits
491  const double a = std::min ( m_a , x ) ;
492  const double b = std::max ( m_a , x ) ;
493 
494  int ierror =
495  gsl_integration_qag ( F->fn ,
496  a , b ,
497  m_epsabs , m_epsrel ,
498  size () , (int) rule() , ws ()->ws ,
499  &m_result , &m_error );
500 
501  if( ierror ) { gsl_error( "NumericalIndefiniteIntegral::QAG " ,
502  __FILE__ , __LINE__ , ierror ) ; }
503 
504  // sign
506  && x < m_a ) { m_result *= -1 ; }
508  && x > m_a ) { m_result *= -1 ; }
509 
510  return m_result ;
511  }
StatusCode Exception(const std::string &message, const StatusCode &sc=StatusCode::FAILURE) const
GaudiMath::Integration::Limit limit() const
integration limit
GaudiMath::Integration::KronrodRule rule() const
integration rule
_Workspace * allocate() const
allocate the integration workspace
double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::QAG ( _Function fun) const
protected
double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::QAGI ( _Function fun) const
protected

Definition at line 346 of file NumericalIndefiniteIntegral.cpp.

347  {
348  // check the argument
349  if( !F ) { Exception("::QAGI: invalid function"); }
350 
351  const double x = m_argument[m_index] ;
352 
353  // allocate workspace
354  allocate() ;
355 
356  int ierror = 0 ;
357  switch ( limit() )
358  {
360  ierror = gsl_integration_qagiu ( F->fn , x ,
361  m_epsabs , m_epsrel ,
362  size () , ws()->ws ,
363  &m_result , &m_error ) ; break ;
365  ierror = gsl_integration_qagil ( F->fn , x ,
366  m_epsabs , m_epsrel ,
367  size () , ws()->ws ,
368  &m_result , &m_error ) ; break ;
369  default :
370  Exception ( "::QAGI: invalid mode" ) ;
371  };
372 
373  if( ierror ) { gsl_error( "NumericalIndefiniteIntegral::QAGI" ,
374  __FILE__ , __LINE__ , ierror ) ;}
375 
376  return m_result ;
377  }
StatusCode Exception(const std::string &message, const StatusCode &sc=StatusCode::FAILURE) const
GaudiMath::Integration::Limit limit() const
integration limit
_Workspace * allocate() const
allocate the integration workspace
double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::QAGI ( _Function fun) const
protected
double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::QAGP ( _Function fun) const
protected
double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::QAGP ( _Function fun) const
protected

Definition at line 383 of file NumericalIndefiniteIntegral.cpp.

384  {
385  if( !F ) { Exception("QAGP::invalid function") ; }
386 
387  const double x = m_argument[m_index] ;
388  if ( m_a == x )
389  {
390  m_result = 0 ;
391  m_error = 0 ; // EXACT !
392  return m_result ;
393  }
394 
395  // no known singular points ?
396  if( points().empty() ) { return QAGS( F ) ; }
397 
398  // integration limits
399  const double a = std::min ( m_a , x ) ;
400  const double b = std::max ( m_a , x ) ;
401 
402  // "active" singular points
403  auto lower = std::lower_bound( points().begin(), points().end(), a ) ;
404  auto upper = std::upper_bound( points().begin(), points().end(), b ) ;
405 
406  Points pnts ( upper - lower ) ;
407  std::copy( lower , upper , pnts.begin() );
408  if ( *lower != a ) { pnts.insert( pnts.begin () , a ) ; }
409  if ( *upper != b ) { pnts.insert( pnts.end () , b ) ; }
410  std::copy( pnts.begin() , pnts.end() , m_pdata.get() );
411  const size_t npts = pnts.size() ;
412 
413  // use GSL
414  int ierror =
415  gsl_integration_qagp ( F->fn ,
416  m_pdata.get() , npts ,
417  m_epsabs , m_epsrel ,
418  size () , ws()->ws ,
419  &m_result , &m_error ) ;
420 
421  if( ierror ) { gsl_error( "NumericalIndefiniteIntegral::QAGI " ,
422  __FILE__ , __LINE__ , ierror ) ; }
423 
424  // sign
426  && x < m_a ) { m_result *= -1 ; }
428  && x > m_a ) { m_result *= -1 ; }
429 
430  return m_result ;
431  }
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:45
StatusCode Exception(const std::string &message, const StatusCode &sc=StatusCode::FAILURE) const
GaudiMath::Integration::Limit limit() const
integration limit
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:47
std::vector< double > Points
typedef for vector of singular points
double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::QAGS ( _Function fun) const
protected

Definition at line 517 of file NumericalIndefiniteIntegral.cpp.

518  {
519  if( !F ) { Exception("QAG::invalid function") ; }
520 
521  const double x = m_argument[m_index] ;
522  if ( m_a == x )
523  {
524  m_result = 0 ;
525  m_error = 0 ; // EXACT !
526  return m_result ;
527  }
528 
529  // allocate workspace
530  allocate () ;
531 
532  // integration limits
533  const double a = std::min ( m_a , x ) ;
534  const double b = std::max ( m_a , x ) ;
535 
536  int ierror =
537  gsl_integration_qags ( F->fn ,
538  a , b ,
539  m_epsabs , m_epsrel ,
540  size () , ws()->ws ,
541  &m_result , &m_error );
542 
543  if( ierror ) { gsl_error( "NumericalIndefiniteIntegral::QAGS " ,
544  __FILE__ , __LINE__ , ierror ) ; }
545 
546  // sign
548  && x < m_a ) { m_result *= -1 ; }
550  && x > m_a ) { m_result *= -1 ; }
551 
552  return m_result ;
553  }
StatusCode Exception(const std::string &message, const StatusCode &sc=StatusCode::FAILURE) const
GaudiMath::Integration::Limit limit() const
integration limit
_Workspace * allocate() const
allocate the integration workspace
double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::QAGS ( _Function fun) const
protected
double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::QNG ( _Function fun) const
protected
double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::QNG ( _Function fun) const
protected

Definition at line 437 of file NumericalIndefiniteIntegral.cpp.

438  {
439  if( !F ) { Exception("QNG::invalid function") ; }
440 
441  const double x = m_argument[m_index] ;
442  if ( m_a == x )
443  {
444  m_result = 0 ;
445  m_error = 0 ; // EXACT !
446  return m_result ;
447  }
448 
449  // integration limits
450  const double a = std::min ( m_a , x ) ;
451  const double b = std::max ( m_a , x ) ;
452 
453  size_t neval = 0 ;
454  int ierror =
455  gsl_integration_qng ( F->fn ,
456  a , b ,
457  m_epsabs , m_epsrel ,
458  &m_result , &m_error , &neval ) ;
459 
460  if( ierror ) { gsl_error( "NumericalIndefiniteIntegral::QNG " ,
461  __FILE__ , __LINE__ , ierror ) ; }
462 
463  // sign
465  && x < m_a ) { m_result *= -1 ; }
467  && x > m_a ) { m_result *= -1 ; }
468 
469  return m_result ;
470  }
StatusCode Exception(const std::string &message, const StatusCode &sc=StatusCode::FAILURE) const
GaudiMath::Integration::Limit limit() const
integration limit
double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::result ( ) const
inline
double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::result ( ) const
inline
GaudiMath::Integration::KronrodRule Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::rule ( ) const
inline

integration rule

Definition at line 322 of file NumericalIndefiniteIntegral.h.

322 { return m_rule ; }
GaudiMath::Integration::KronrodRule Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::rule ( ) const
inline

integration rule

Definition at line 322 of file NumericalIndefiniteIntegral.h.

322 { return m_rule ; }
size_t Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::size ( ) const
inline
size_t Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::size ( ) const
inline
GaudiMath::Integration::Type Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::type ( ) const
inline

integration type

Definition at line 316 of file NumericalIndefiniteIntegral.h.

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

integration type

Definition at line 316 of file NumericalIndefiniteIntegral.h.

_Workspace* Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::ws ( ) const
inlineprotected

Definition at line 340 of file NumericalIndefiniteIntegral.h.

341  { return m_ws.get(); }
_Workspace* Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::ws ( ) const
inlineprotected

Definition at line 340 of file NumericalIndefiniteIntegral.h.

341  { return m_ws.get(); }

Member Data Documentation

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

Definition at line 370 of file NumericalIndefiniteIntegral.h.

Argument Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_argument
mutableprivate

Definition at line 389 of file NumericalIndefiniteIntegral.h.

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

Definition at line 374 of file NumericalIndefiniteIntegral.h.

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

Definition at line 367 of file NumericalIndefiniteIntegral.h.

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

Definition at line 380 of file NumericalIndefiniteIntegral.h.

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

Definition at line 381 of file NumericalIndefiniteIntegral.h.

double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_error
mutableprivate

Definition at line 384 of file NumericalIndefiniteIntegral.h.

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

Definition at line 366 of file NumericalIndefiniteIntegral.h.

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

Definition at line 368 of file NumericalIndefiniteIntegral.h.

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

Definition at line 372 of file NumericalIndefiniteIntegral.h.

std::unique_ptr< double[]> Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_pdata
private

Definition at line 378 of file NumericalIndefiniteIntegral.h.

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

Definition at line 377 of file NumericalIndefiniteIntegral.h.

double Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_result
mutableprivate

Definition at line 383 of file NumericalIndefiniteIntegral.h.

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

Definition at line 375 of file NumericalIndefiniteIntegral.h.

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

Definition at line 386 of file NumericalIndefiniteIntegral.h.

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

Definition at line 373 of file NumericalIndefiniteIntegral.h.

std::unique_ptr< _Workspace, gsl_ws_deleter > Genfun::GaudiMathImplementation::NumericalIndefiniteIntegral::m_ws
mutableprivate

Definition at line 387 of file NumericalIndefiniteIntegral.h.


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