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 ,
126 {
Exception(
"::constructor: invalid dimensionality ") ; }
128 {
Exception(
"::constructor: invalid variable index") ; }
130 m_DIM =
function.dimensionality() - 1 ;
147 (
const AbsFunction&
function ,
152 const double epsabs ,
153 const double epsrel ,
159 ,
m_type ( GaudiMath::Integration:: Other )
161 ,
m_rule ( GaudiMath::Integration:: Fixed )
168 {
Exception(
"::constructor: invalid dimensionality ") ; }
170 {
Exception(
"::constructor: invalid variable index") ; }
172 m_DIM =
function.dimensionality() - 1 ;
180 [&](
double x) {
return x<lim.first || lim.second<x; } );
213 (
const AbsFunction&
function ,
217 const double epsabs ,
218 const double epsrel ,
224 ,
m_type ( GaudiMath::Integration:: Other )
226 ,
m_rule ( GaudiMath::Integration:: Fixed )
232 {
Exception(
"::constructor: invalid dimensionality ") ; }
234 {
Exception(
"::constructor: invalid variable index") ; }
236 m_DIM =
function.dimensionality() - 1 ;
269 (
const AbsFunction&
function ,
273 const double epsabs ,
274 const double epsrel ,
280 ,
m_type ( GaudiMath::Integration:: Other )
282 ,
m_rule ( GaudiMath::Integration:: Fixed )
289 {
Exception(
"::constructor: invalid dimensionality ") ; }
291 {
Exception(
"::constructor: invalid variable index") ; }
293 m_DIM =
function.dimensionality() - 1 ;
322 (
const AbsFunction&
function ,
330 ,
m_type ( GaudiMath::Integration:: Other )
332 ,
m_rule ( GaudiMath::Integration:: Fixed )
338 {
Exception(
"::constructor: invalid dimensionality ") ; }
340 {
Exception(
"::constructor: invalid variable index") ; }
342 m_DIM =
function.dimensionality() - 1 ;
377 "*GaudiMath*" , sc ) ;
392 if( 1 !=
m_DIM ) {
Exception (
"operator(): invalid argument size " ) ; };
406 {
Exception (
"::partial(i): invalid variable index " ) ; };
409 return Genfun::FunctionNoop( &aux ) ;
424 if( argument.dimension() !=
m_DIM )
425 {
Exception (
"operator(): invalid argument size " ) ; };
429 for(
size_t i = 0 ; i <
m_DIM ; ++i ) {
431 const size_t j = i <
m_index ? i : i + 1 ;
432 m_argF [j] = argument [i] ;
446 {
return QAGI ( &F1 ) ; }
460 default:
Exception (
"::operator(): invalid type " );
463 default:
Exception (
"::operator(): invalid category " );
478 m_ws->ws = gsl_integration_workspace_alloc( size () );
479 if ( !
m_ws->ws ) {
Exception (
"allocate()::invalid workspace" ) ; };
491 if ( !F ) {
Exception(
"::QAGI: invalid function"); }
499 ierror = gsl_integration_qagi ( F->
fn ,
504 ierror = gsl_integration_qagil ( F->
fn ,
m_b ,
509 ierror = gsl_integration_qagiu ( F->
fn ,
m_a ,
513 }
else {
Exception (
"::QAGI: invalid mode" ) ; };
515 if( ierror ) { gsl_error(
"NumericalDefiniteIntegral::QAGI" ,
516 __FILE__ , __LINE__ , ierror ) ;}
527 if( !F ) {
Exception(
"QAGP::invalid function") ; }
534 gsl_integration_qagp ( F->
fn ,
535 const_cast<double*>(points().data()) ,
points().
size() ,
540 if( ierror ) { gsl_error(
"NumericalDefiniteIntegral::QAGI " ,
541 __FILE__ , __LINE__ , ierror ) ; }
555 if( !F ) {
Exception(
"QNG::invalid function") ; }
562 gsl_integration_qng ( F->
fn ,
563 lim.first , lim.second,
567 if( ierror ) { gsl_error(
"NumericalIndefiniteIntegral::QNG " ,
568 __FILE__ , __LINE__ , ierror ) ; }
582 if( !F ) {
Exception(
"QAG::invalid function") ; }
591 gsl_integration_qag ( F->
fn ,
592 lim.first , lim.second,
594 size () , (
int)
rule() ,
ws ()->
ws ,
597 if( ierror ) { gsl_error(
"NumericalDefiniteIntegral::QAG " ,
598 __FILE__ , __LINE__ , ierror ) ; }
611 if( !F ) {
Exception(
"QAG::invalid function") ; }
626 gsl_integration_qags ( F->
fn ,
627 lim.first , lim.second,
632 if( ierror ) { gsl_error(
"NumericalDefiniteIntegral::QAGS " ,
633 __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.
GaudiMath::Integration::Category m_category
double operator()(double argument) const override
Function value.
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
auto end(reverse_wrapper< T > &w)
double GSL_Adaptor(double x, void *params)
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: