11 #include "gsl/gsl_errno.h" 12 #include "gsl/gsl_integration.h" 32 #pragma warning(disable:1572) 38 #pragma warning(disable:4996) 43 namespace GaudiMathImplementation
47 { gsl_function*
fn ; };
103 (
const AbsFunction&
function ,
131 {
Exception(
"::constructor: invalid dimensionality ") ; }
133 {
Exception(
"::constructor: invalid variable index") ; }
135 m_DIM =
function.dimensionality() - 1 ;
152 (
const AbsFunction&
function ,
157 const double epsabs ,
158 const double epsrel ,
167 ,
m_type ( GaudiMath::Integration:: Other )
169 ,
m_rule ( GaudiMath::Integration:: Fixed )
180 {
Exception(
"::constructor: invalid dimensionality ") ; }
182 {
Exception(
"::constructor: invalid variable index") ; }
184 m_DIM =
function.dimensionality() - 1 ;
188 const double l1 =
std::min ( a , b ) ;
189 const double l2 =
std::max ( a , b ) ;
232 (
const AbsFunction&
function ,
236 const double epsabs ,
237 const double epsrel ,
246 ,
m_type ( GaudiMath::Integration:: Other )
248 ,
m_rule ( GaudiMath::Integration:: Fixed )
258 {
Exception(
"::constructor: invalid dimensionality ") ; }
260 {
Exception(
"::constructor: invalid variable index") ; }
262 m_DIM =
function.dimensionality() - 1 ;
295 (
const AbsFunction&
function ,
299 const double epsabs ,
300 const double epsrel ,
309 ,
m_type ( GaudiMath::Integration:: Other )
311 ,
m_rule ( GaudiMath::Integration:: Fixed )
321 {
Exception(
"::constructor: invalid dimensionality ") ; }
323 {
Exception(
"::constructor: invalid variable index") ; }
325 m_DIM =
function.dimensionality() - 1 ;
354 (
const AbsFunction&
function ,
367 ,
m_type ( GaudiMath::Integration:: Other )
369 ,
m_rule ( GaudiMath::Integration:: Fixed )
379 {
Exception(
"::constructor: invalid dimensionality ") ; }
381 {
Exception(
"::constructor: invalid variable index") ; }
383 m_DIM =
function.dimensionality() - 1 ;
427 "*GaudiMath*" , sc ) ;
435 double NumericalDefiniteIntegral::operator()
436 (
const double argument )
const 443 if( 1 !=
m_DIM ) {
Exception (
"operator(): invalid argument size " ) ; };
457 {
Exception (
"::partial(i): invalid variable index " ) ; };
460 return Genfun::FunctionNoop( &aux ) ;
468 double NumericalDefiniteIntegral::operator()
469 (
const Argument& argument )
const 476 if( argument.dimension() !=
m_DIM )
477 {
Exception (
"operator(): invalid argument size " ) ; };
481 for(
size_t i = 0 ; i <
m_DIM ; ++i )
484 const size_t j = i <
m_index ? i : i + 1 ;
485 m_argF [j] = argument [i] ;
499 {
return QAGI ( &F1 ) ; }
508 {
return QAGP ( &F1 ) ; }
511 {
return QNG ( &F1 ) ; }
513 {
return QAG ( &F1 ) ; }
515 {
return QAGS ( &F1 ) ; }
517 {
Exception (
"::operator(): invalid type " ); }
519 {
Exception (
"::operator(): invalid category " ); }
533 m_ws->ws = gsl_integration_workspace_alloc( size () );
534 if ( !
m_ws->ws ) {
Exception (
"allocate()::invalid workspace" ) ; };
546 if ( !F ) {
Exception(
"::QAGI: invalid function"); }
555 ierror = gsl_integration_qagi ( F->
fn ,
562 ierror = gsl_integration_qagil ( F->
fn ,
m_b ,
569 ierror = gsl_integration_qagiu ( F->
fn ,
m_a ,
575 {
Exception (
"::QAGI: invalid mode" ) ; };
577 if( ierror ) { gsl_error(
"NumericalDefiniteIntegral::QAGI" ,
578 __FILE__ , __LINE__ , ierror ) ;}
589 if( !F ) {
Exception(
"QAGP::invalid function") ; }
598 gsl_integration_qagp ( F->
fn ,
604 if( ierror ) { gsl_error(
"NumericalDefiniteIntegral::QAGI " ,
605 __FILE__ , __LINE__ , ierror ) ; }
619 if( !F ) {
Exception(
"QNG::invalid function") ; }
627 gsl_integration_qng ( F->
fn ,
632 if( ierror ) { gsl_error(
"NumericalIndefiniteIntegral::QNG " ,
633 __FILE__ , __LINE__ , ierror ) ; }
648 if( !F ) {
Exception(
"QAG::invalid function") ; }
658 gsl_integration_qag ( F->
fn ,
661 size () , (
int)
rule() ,
ws ()->
ws ,
664 if( ierror ) { gsl_error(
"NumericalDefiniteIntegral::QAG " ,
665 __FILE__ , __LINE__ , ierror ) ; }
679 if( !F ) {
Exception(
"QAG::invalid function") ; }
696 gsl_integration_qags ( F->
fn ,
702 if( ierror ) { gsl_error(
"NumericalDefiniteIntegral::QAGS " ,
703 __FILE__ , __LINE__ , ierror ) ; }
GaudiMath::Integration::Category category() const
integration category
StatusCode Exception(const std::string &message, const StatusCode &sc=StatusCode::FAILURE) const
Define general base for Gaudi exception.
gsl_integration_workspace * ws
GaudiMath::Integration::Category m_category
Genfun::Derivative partial(unsigned int index) const override
Derivatives.
std::unique_ptr< _Workspace, gsl_ws_deleter > m_ws
NumericalDefiniteIntegral()
Genfun::GaudiMathImplementation::NumericalDerivative Derivative
unsigned int dimensionality() const override
dimensionality of the problem
double epsabs() const
absolute precision
GaudiMath::Integration::KronrodRule m_rule
This class is used for returning status codes from appropriate routines.
Type
type of integration (for finite limits)
double QAG(_Function *fun) const
double GSL_Adaptor(double x, void *params)
std::unique_ptr< double[]> m_pdata
double epsrel() const
relatiove precision
Numerical derivative (using GSL adaptive numerical differentiation)
_Workspace * allocate() const
allocate the integration workspace
GaudiMath::Integration::Type m_type
GaudiMath::Integration::Type type() const
integration type
std::unique_ptr< const AbsFunction > m_function
const Points & points() const
known singularities
double QAGP(_Function *fun) const
KronrodRule
integration rule
double QNG(_Function *fun) const
double QAGI(_Function *fun) const
the simple structure to be used for adaption interface Genfun::AbsFunction to gsl_function structure ...
GaudiMath::Integration::KronrodRule rule() const
integration rule
double a() const
integration limit
double QAGS(_Function *fun) const
This class allows the numerical evaluation of the following functions: