11 #include "gsl/gsl_errno.h" 12 #include "gsl/gsl_integration.h" 38 #pragma warning(disable:1572) 44 #pragma warning(disable:4996) 49 namespace GaudiMathImplementation
53 { gsl_function*
fn ; };
74 (
const AbsFunction&
function ,
107 {
Exception(
"::constructor: invalid variable index") ; }
122 (
const AbsFunction&
function ,
127 const double epsabs ,
128 const double epsrel ,
136 ,
m_type ( GaudiMath::Integration:: Other )
138 ,
m_rule ( GaudiMath::Integration:: Fixed )
150 {
Exception(
"::constructor: invalid variable index") ; }
168 (
const AbsFunction&
function ,
171 const double epsabs ,
172 const double epsrel ,
180 ,
m_type ( GaudiMath::Integration:: Other )
182 ,
m_rule ( GaudiMath::Integration:: Fixed )
192 {
Exception(
"::constructor: invalid variable index") ; }
232 "*GaudiMath*" , sc ) ;
240 double NumericalIndefiniteIntegral::operator()
241 (
const double argument )
const 248 if( 1 !=
m_DIM ) {
Exception (
"operator(): invalid argument size " ) ; };
262 {
Exception (
"::partial(i): invalid variable index " ) ; };
266 return Genfun::FunctionNoop( &aux ) ;
270 const AbsFunction& aux = -1 *
function() ;
271 return Genfun::FunctionNoop( &aux ) ;
273 const AbsFunction& aux =
function() ;
274 return Genfun::FunctionNoop( &aux ) ;
280 double NumericalIndefiniteIntegral::operator()
281 (
const Argument& argument )
const 288 if( argument.dimension() !=
m_DIM )
289 {
Exception (
"operator(): invalid argument size " ) ; };
305 {
return QAGI ( &F1 ) ; }
307 {
return QAGP ( &F1 ) ; }
310 {
return QNG ( &F1 ) ; }
312 {
return QAG ( &F1 ) ; }
314 {
return QAGS ( &F1 ) ; }
316 {
Exception (
"::operator(): invalid type " ); }
318 {
Exception (
"::operator(): invalid category " ); }
332 m_ws->ws = gsl_integration_workspace_alloc( size () );
333 if ( !
m_ws->ws ) {
Exception (
"allocate()::invalid workspace" ) ; };
345 if( !F ) {
Exception(
"::QAGI: invalid function"); }
356 ierror = gsl_integration_qagiu ( F->
fn , x ,
361 ierror = gsl_integration_qagil ( F->
fn , x ,
369 if( ierror ) { gsl_error(
"NumericalIndefiniteIntegral::QAGI" ,
370 __FILE__ , __LINE__ , ierror ) ;}
381 if( !F ) {
Exception(
"QAGP::invalid function") ; }
402 Points pnts ( upper - lower ) ;
404 if ( *lower != a ) { pnts.
insert( pnts.
begin () ,
a ) ; }
405 if ( *upper != b ) { pnts.
insert( pnts.
end () , b ) ; }
407 const size_t npts = pnts.
size() ;
411 gsl_integration_qagp ( F->
fn ,
417 if( ierror ) { gsl_error(
"NumericalIndefiniteIntegral::QAGI " ,
418 __FILE__ , __LINE__ , ierror ) ; }
435 if( !F ) {
Exception(
"QNG::invalid function") ; }
451 gsl_integration_qng ( F->
fn ,
456 if( ierror ) { gsl_error(
"NumericalIndefiniteIntegral::QNG " ,
457 __FILE__ , __LINE__ , ierror ) ; }
473 if( !F ) {
Exception(
"QAG::invalid function") ; }
491 gsl_integration_qag ( F->
fn ,
494 size () , (
int)
rule() ,
ws ()->
ws ,
497 if( ierror ) { gsl_error(
"NumericalIndefiniteIntegral::QAG " ,
498 __FILE__ , __LINE__ , ierror ) ; }
515 if( !F ) {
Exception(
"QAG::invalid function") ; }
533 gsl_integration_qags ( F->
fn ,
539 if( ierror ) { gsl_error(
"NumericalIndefiniteIntegral::QAGS " ,
540 __FILE__ , __LINE__ , ierror ) ; }
std::unique_ptr< _Workspace, gsl_ws_deleter > m_ws
Genfun::Derivative partial(unsigned int index) const override
Derivatives.
Define general base for Gaudi exception.
double epsrel() const
relatiove precision
StatusCode Exception(const std::string &message, const StatusCode &sc=StatusCode::FAILURE) const
std::unique_ptr< double[]> m_pdata
double QAGI(_Function *fun) const
GaudiMath::Integration::Limit limit() const
integration limit
Genfun::GaudiMathImplementation::NumericalDerivative Derivative
gsl_integration_workspace * ws
GaudiMath::Integration::Category category() const
integration category
auto begin(reverse_wrapper< T > &w)
double QAGS(_Function *fun) const
GaudiMath::Integration::KronrodRule rule() const
integration rule
This class is used for returning status codes from appropriate routines.
_Workspace * allocate() const
allocate the integration workspace
Type
type of integration (for finite limits)
double QNG(_Function *fun) const
auto end(reverse_wrapper< T > &w)
double epsabs() const
absolute precision
double GSL_Adaptor(double x, void *params)
double QAG(_Function *fun) const
Numerical derivative (using GSL adaptive numerical differentiation)
GaudiMath::Integration::Limit m_limit
GaudiMath::Integration::Category m_category
unsigned int dimensionality() const override
dimensionality of the problem
GaudiMath::Integration::Type type() const
integration type
std::unique_ptr< const AbsFunction > m_function
double a() const
integration limit
GaudiMath::Integration::Type m_type
Limit
how to distinguish variable low and variable high limits
KronrodRule
integration rule
GaudiMath::Integration::KronrodRule m_rule
double QAGP(_Function *fun) const
the simple structure to be used for adaption interface Genfun::AbsFunction to gsl_function structure ...
NumericalIndefiniteIntegral()
The simple class for numerical integrations.
const Points & points() const
known singularities