14 #include "gsl/gsl_errno.h"
15 #include "gsl/gsl_integration.h"
41 #pragma warning(disable:1572)
47 #pragma warning(disable:4996)
52 namespace GaudiMathImplementation
56 { gsl_integration_workspace*
ws ; };
58 { gsl_function*
fn ; };
83 ( const AbsFunction& function ,
93 , m_function ( function.clone() )
94 , m_DIM ( function.dimensionality() )
105 , m_epsabs ( epsabs )
106 , m_epsrel ( epsrel )
108 , m_result ( GSL_NEGINF )
109 , m_error ( GSL_POSINF )
113 , m_argument ( function.dimensionality() )
117 if ( m_index >= m_DIM )
118 { Exception(
"::constructor: invalid variable index") ; }
133 (
const AbsFunction&
function ,
138 const double epsabs ,
139 const double epsrel ,
142 , m_function (
function.clone() )
143 , m_DIM (
function.dimensionality() )
150 , m_points ( points )
152 , m_epsabs ( epsabs )
153 , m_epsrel ( epsrel )
155 , m_result ( GSL_NEGINF )
156 , m_error ( GSL_POSINF )
160 , m_argument (
function.dimensionality() )
162 if ( m_index >= m_DIM )
163 { Exception(
"::constructor: invalid variable index") ; }
164 m_pdata =
new double[ 2 + m_points.size() ] ;
165 m_points.push_back( a ) ;
166 std::sort( m_points.begin() , m_points.end() ) ;
168 m_points.end () ) , m_points.end() );
181 (
const AbsFunction&
function ,
184 const double epsabs ,
185 const double epsrel ,
188 , m_function (
function.clone() )
189 , m_DIM (
function.dimensionality() )
198 , m_epsabs ( epsabs )
199 , m_epsrel ( epsrel )
200 , m_result ( GSL_NEGINF )
201 , m_error ( GSL_POSINF )
204 , m_argument (
function.dimensionality() )
206 if ( m_index >= m_DIM )
207 { Exception(
"::constructor: invalid variable index") ; }
218 , m_function ( right.m_function->clone() )
219 , m_DIM ( right.m_DIM )
220 , m_index ( right.m_index )
222 , m_limit ( right.m_limit )
223 , m_type ( right.m_type )
224 , m_category ( right.m_category )
225 , m_rule ( right.m_rule )
226 , m_points ( right.m_points )
228 , m_epsabs ( right.m_epsabs )
229 , m_epsrel ( right.m_epsrel )
230 , m_result ( GSL_NEGINF )
231 , m_error ( GSL_POSINF )
232 , m_size ( right.m_size )
234 , m_argument ( right.m_argument )
248 gsl_integration_workspace_free (
m_ws->
ws ) ;
265 "*GaudiMath*" , sc ) ;
273 double NumericalIndefiniteIntegral::operator()
274 (
const double argument )
const
277 m_result = GSL_NEGINF ;
278 m_error = GSL_POSINF ;
281 if( 1 != m_DIM ) { Exception (
"operator(): invalid argument size " ) ; };
283 m_argument[0] = argument ;
284 return (*
this) ( m_argument );
295 {
Exception (
"::partial(i): invalid variable index " ) ; };
299 return Genfun::FunctionNoop( &aux ) ;
303 const AbsFunction& aux = -1 *
function() ;
304 return Genfun::FunctionNoop( &aux ) ;
306 const AbsFunction& aux =
function() ;
307 return Genfun::FunctionNoop( &aux ) ;
313 double NumericalIndefiniteIntegral::operator()
314 (
const Argument& argument )
const
317 m_result = GSL_NEGINF ;
318 m_error = GSL_POSINF ;
321 if( argument.dimension() != m_DIM )
322 { Exception (
"operator(): invalid argument size " ) ; };
325 {
for(
size_t i = 0 ;
i < m_DIM ; ++
i ){ m_argument[
i] = argument[
i];}}
328 GSL_Helper helper( *m_function , m_argument , m_index );
338 {
return QAGI ( &F1 ) ; }
340 {
return QAGP ( &F1 ) ; }
343 {
return QNG ( &F1 ) ; }
345 {
return QAG ( &F1 ) ; }
347 {
return QAGS ( &F1 ) ; }
349 { Exception (
"::operator(): invalid type " ); }
351 { Exception (
"::operator(): invalid category " ); }
364 gsl_integration_workspace* aux =
365 gsl_integration_workspace_alloc( size () );
366 if ( 0 == aux ) {
Exception (
"allocate()::invalid workspace" ) ; };
379 if( 0 == F ) {
Exception(
"::QAGI: invalid function"); }
390 ierror = gsl_integration_qagiu ( F->
fn , x ,
395 ierror = gsl_integration_qagil ( F->
fn , x ,
403 if( ierror ) { gsl_error(
"NumericalIndefiniteIntegral::QAGI" ,
404 __FILE__ , __LINE__ , ierror ) ;}
415 if( 0 == F ) {
Exception(
"QAGP::invalid function") ; }
438 Points pnts ( upper - lower ) ;
440 if ( *lower != a ) { pnts.
insert( pnts.
begin () ,
a ) ; }
441 if ( *upper != b ) { pnts.
insert( pnts.
end () , b ) ; }
443 const size_t npts = pnts.
size() ;
447 gsl_integration_qagp ( F->
fn ,
453 if( ierror ) { gsl_error(
"NumericalIndefiniteIntegral::QAGI " ,
454 __FILE__ , __LINE__ , ierror ) ; }
471 if( 0 == F ) {
Exception(
"QNG::invalid function") ; }
487 gsl_integration_qng ( F->
fn ,
492 if( ierror ) { gsl_error(
"NumericalIndefiniteIntegral::QNG " ,
493 __FILE__ , __LINE__ , ierror ) ; }
509 if( 0 == F ) {
Exception(
"QAG::invalid function") ; }
527 gsl_integration_qag ( F->
fn ,
530 size () , (
int)
rule() ,
ws ()->
ws ,
533 if( ierror ) { gsl_error(
"NumericalIndefiniteIntegral::QAG " ,
534 __FILE__ , __LINE__ , ierror ) ; }
551 if( 0 == F ) {
Exception(
"QAG::invalid function") ; }
569 gsl_integration_qags ( F->
fn ,
575 if( ierror ) { gsl_error(
"NumericalIndefiniteIntegral::QAGS " ,
576 __FILE__ , __LINE__ , ierror ) ; }