| # Gaudi Framework, version v21r10p1 |

Home |  | Generated: 29 Jul 2010

# Integral.cpp

Go to the documentation of this file.

    00001 // $Id: Integral.cpp,v 1.2 2007/11/20 13:00:17 marcocle Exp $
    00002 // ============================================================================
    00003 // Include files
    00004 // ============================================================================
    00005 // GaudiKernel
    00006 // ============================================================================
    00007 #include "GaudiKernel/GaudiException.h"
    00008 // ============================================================================
    00009 // GaudiMath
    00010 // ============================================================================
    00011 #include "GaudiMath/Integral.h"
    00012 #include "GaudiMath/NumericalDefiniteIntegral.h"
    00013 #include "GaudiMath/Constant.h"
    00014 // ============================================================================
    00015
    00016 #ifdef __ICC
    00017 // disable icc remark #1572: floating-point equality and inequality comparisons are unreliable
    00018 //   The comparison are meant
    00019 #pragma warning(disable:1572)
    00020 #endif
    00021
    00022 namespace GaudiMath
    00023 {
    00024
    00025   double Integral
    00026   ( const Genfun::AbsFunction&                function ,
    00027     const double                              a        ,
    00028     const double                              b        ,
    00029     const GaudiMath::Integration::Type        type     ,
    00030     const GaudiMath::Integration::KronrodRule rule     ,
    00031     const double                              epsabs   ,
    00032     const double                              epsrel   ,
    00033     const size_t                              size     )
    00034   {
    00035     if ( 1 != function.dimensionality() )
    00036       { throw GaudiException
    00037           ("GaudiMath::Integral: illegal function dimension" ,
    00038            "*GaudiMath*" , StatusCode::FAILURE ); }
    00039
    00040     const Genfun::AbsFunction& one   =
    00041       Genfun::GaudiMathImplementation::Constant ( 1.0 , 1 ) ;
    00042
    00043     const Genfun::AbsFunction& cross =
    00044       Genfun::FunctionDirectProduct (&one , &function ) ;
    00045
    00046     const Genfun::AbsFunction& result =
    00047       Genfun::GaudiMathImplementation::NumericalDefiniteIntegral
    00048       ( cross , 1 , a , b, type , rule , epsabs , epsrel , size ) ;
    00049
    00050     return result( Genfun::Argument(1) ) ;
    00051   }
    00052
    00053   double Integral
    00054   ( const Genfun::AbsFunction&                 function  ,
    00055     const double                               a         ,
    00056     const double                               b         ,
    00057     const std::vector<double>&                 points    ,
    00058     const double                               epsabs    ,
    00059     const double                               epsrel    ,
    00060     const size_t                               size      )
    00061   {
    00062
    00063   if ( 1 != function.dimensionality() )
    00064       { throw GaudiException
    00065           ("GaudiMath::Integral: illegal function dimension" ,
    00066            "*GaudiMath*" , StatusCode::FAILURE ); }
    00067
    00068     const Genfun::AbsFunction& one   =
    00069       Genfun::GaudiMathImplementation::Constant ( 1.0 , 1 ) ;
    00070
    00071     const Genfun::AbsFunction& cross =
    00072       Genfun::FunctionDirectProduct (&one , &function ) ;
    00073
    00074     const Genfun::AbsFunction& result =
    00075       Genfun::GaudiMathImplementation::NumericalDefiniteIntegral
    00076       ( cross , 1 , a , b, points , epsabs , epsrel , size ) ;
    00077
    00078     return result( Genfun::Argument(1) ) ;
    00079   }
    00080
    00081   double Integral
    00082   ( const Genfun::AbsFunction&                 function  ,
    00083     const double                               a         ,
    00084     const GaudiMath::Integration::Inf          b         ,
    00085     const double                               epsabs    ,
    00086     const double                               epsrel    ,
    00087     const size_t                               size      )
    00088   {
    00089     if ( 1 != function.dimensionality() )
    00090       { throw GaudiException
    00091           ("GaudiMath::Integral: illegal function dimension" ,
    00092            "*GaudiMath*" , StatusCode::FAILURE ); }
    00093
    00094     const Genfun::AbsFunction& one   =
    00095       Genfun::GaudiMathImplementation::Constant ( 1.0 , 1 ) ;
    00096
    00097     const Genfun::AbsFunction& cross =
    00098       Genfun::FunctionDirectProduct (&one , &function ) ;
    00099
    00100     const Genfun::AbsFunction& result =
    00101       Genfun::GaudiMathImplementation::NumericalDefiniteIntegral
    00102       ( cross , 1 , a , b , epsabs , epsrel , size ) ;
    00103
    00104     return result( Genfun::Argument(1) ) ;
    00105   }
    00106
    00107   double Integral
    00108   ( const Genfun::AbsFunction&                 function  ,
    00109     const GaudiMath::Integration::Inf          a         ,
    00110     const double                               b         ,
    00111     const double                               epsabs    ,
    00112     const double                               epsrel    ,
    00113     const size_t                               size      )
    00114   {
    00115     if ( 1 != function.dimensionality() )
    00116       { throw GaudiException
    00117           ("GaudiMath::Integral: illegal function dimension" ,
    00118            "*GaudiMath*" , StatusCode::FAILURE ); }
    00119
    00120     const Genfun::AbsFunction& one   =
    00121       Genfun::GaudiMathImplementation::Constant ( 1.0 , 1 ) ;
    00122
    00123     const Genfun::AbsFunction& cross =
    00124       Genfun::FunctionDirectProduct (&one , &function ) ;
    00125
    00126     const Genfun::AbsFunction& result =
    00127       Genfun::GaudiMathImplementation::NumericalDefiniteIntegral
    00128       ( cross , 1 , a , b , epsabs , epsrel , size ) ;
    00129
    00130     return result( Genfun::Argument(1) ) ;
    00131   }
    00132
    00133
    00134
    00135   double Integral
    00136   ( const Genfun::AbsFunction&                 function  ,
    00137     const GaudiMath::Integration::Inf          /* a  */  ,
    00138     const GaudiMath::Integration::Inf          /* b  */  ,
    00139     const double                               epsabs    ,
    00140     const double                               epsrel    ,
    00141     const size_t                               size      )
    00142   {
    00143     if ( 1 != function.dimensionality() )
    00144       { throw GaudiException
    00145           ("GaudiMath::Integral: illegal function dimension" ,
    00146            "*GaudiMath*" , StatusCode::FAILURE ); }
    00147
    00148     const Genfun::AbsFunction& one   =
    00149       Genfun::GaudiMathImplementation::Constant ( 1.0 , 1 ) ;
    00150
    00151     const Genfun::AbsFunction& cross =
    00152       Genfun::FunctionDirectProduct (&one , &function ) ;
    00153
    00154     // FIXME: (MCl) the static_cast below are needed to avoid warnings and to
    00155     // match the signature in NumericalDefiniteIntegral.h (around line 288).
    00156     const Genfun::AbsFunction& result =
    00157       Genfun::GaudiMathImplementation::NumericalDefiniteIntegral
    00158       ( cross , 1 , static_cast<float>(epsabs) , static_cast<float>(epsrel) , size ) ;
    00159
    00160     return result( Genfun::Argument(1) ) ;
    00161   }
    00162
    00163
    00164
    00165
    00166
    00167
    00168 }
    00169
    00170
    00171 // ============================================================================
    00172 // The END
    00173 // ============================================================================
    00174