| # Gaudi Framework, version v21r8 |

Home |  | Generated: 17 Mar 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 namespace GaudiMath
    00017 {
    00018
    00019   double Integral
    00020   ( const Genfun::AbsFunction&                function ,
    00021     const double                              a        ,
    00022     const double                              b        ,
    00023     const GaudiMath::Integration::Type        type     ,
    00024     const GaudiMath::Integration::KronrodRule rule     ,
    00025     const double                              epsabs   ,
    00026     const double                              epsrel   ,
    00027     const size_t                              size     )
    00028   {
    00029     if ( 1 != function.dimensionality() )
    00030       { throw GaudiException
    00031           ("GaudiMath::Integral: illegal function dimension" ,
    00032            "*GaudiMath*" , StatusCode::FAILURE ); }
    00033
    00034     const Genfun::AbsFunction& one   =
    00035       Genfun::GaudiMathImplementation::Constant ( 1.0 , 1 ) ;
    00036
    00037     const Genfun::AbsFunction& cross =
    00038       Genfun::FunctionDirectProduct (&one , &function ) ;
    00039
    00040     const Genfun::AbsFunction& result =
    00041       Genfun::GaudiMathImplementation::NumericalDefiniteIntegral
    00042       ( cross , 1 , a , b, type , rule , epsabs , epsrel , size ) ;
    00043
    00044     return result( Genfun::Argument(1) ) ;
    00045   }
    00046
    00047   double Integral
    00048   ( const Genfun::AbsFunction&                 function  ,
    00049     const double                               a         ,
    00050     const double                               b         ,
    00051     const std::vector<double>&                 points    ,
    00052     const double                               epsabs    ,
    00053     const double                               epsrel    ,
    00054     const size_t                               size      )
    00055   {
    00056
    00057   if ( 1 != function.dimensionality() )
    00058       { throw GaudiException
    00059           ("GaudiMath::Integral: illegal function dimension" ,
    00060            "*GaudiMath*" , StatusCode::FAILURE ); }
    00061
    00062     const Genfun::AbsFunction& one   =
    00063       Genfun::GaudiMathImplementation::Constant ( 1.0 , 1 ) ;
    00064
    00065     const Genfun::AbsFunction& cross =
    00066       Genfun::FunctionDirectProduct (&one , &function ) ;
    00067
    00068     const Genfun::AbsFunction& result =
    00069       Genfun::GaudiMathImplementation::NumericalDefiniteIntegral
    00070       ( cross , 1 , a , b, points , epsabs , epsrel , size ) ;
    00071
    00072     return result( Genfun::Argument(1) ) ;
    00073   }
    00074
    00075   double Integral
    00076   ( const Genfun::AbsFunction&                 function  ,
    00077     const double                               a         ,
    00078     const GaudiMath::Integration::Inf          b         ,
    00079     const double                               epsabs    ,
    00080     const double                               epsrel    ,
    00081     const size_t                               size      )
    00082   {
    00083     if ( 1 != function.dimensionality() )
    00084       { throw GaudiException
    00085           ("GaudiMath::Integral: illegal function dimension" ,
    00086            "*GaudiMath*" , StatusCode::FAILURE ); }
    00087
    00088     const Genfun::AbsFunction& one   =
    00089       Genfun::GaudiMathImplementation::Constant ( 1.0 , 1 ) ;
    00090
    00091     const Genfun::AbsFunction& cross =
    00092       Genfun::FunctionDirectProduct (&one , &function ) ;
    00093
    00094     const Genfun::AbsFunction& result =
    00095       Genfun::GaudiMathImplementation::NumericalDefiniteIntegral
    00096       ( cross , 1 , a , b , epsabs , epsrel , size ) ;
    00097
    00098     return result( Genfun::Argument(1) ) ;
    00099   }
    00100
    00101   double Integral
    00102   ( const Genfun::AbsFunction&                 function  ,
    00103     const GaudiMath::Integration::Inf          a         ,
    00104     const double                               b         ,
    00105     const double                               epsabs    ,
    00106     const double                               epsrel    ,
    00107     const size_t                               size      )
    00108   {
    00109     if ( 1 != function.dimensionality() )
    00110       { throw GaudiException
    00111           ("GaudiMath::Integral: illegal function dimension" ,
    00112            "*GaudiMath*" , StatusCode::FAILURE ); }
    00113
    00114     const Genfun::AbsFunction& one   =
    00115       Genfun::GaudiMathImplementation::Constant ( 1.0 , 1 ) ;
    00116
    00117     const Genfun::AbsFunction& cross =
    00118       Genfun::FunctionDirectProduct (&one , &function ) ;
    00119
    00120     const Genfun::AbsFunction& result =
    00121       Genfun::GaudiMathImplementation::NumericalDefiniteIntegral
    00122       ( cross , 1 , a , b , epsabs , epsrel , size ) ;
    00123
    00124     return result( Genfun::Argument(1) ) ;
    00125   }
    00126
    00127
    00128
    00129   double Integral
    00130   ( const Genfun::AbsFunction&                 function  ,
    00131     const GaudiMath::Integration::Inf          /* a  */  ,
    00132     const GaudiMath::Integration::Inf          /* b  */  ,
    00133     const double                               epsabs    ,
    00134     const double                               epsrel    ,
    00135     const size_t                               size      )
    00136   {
    00137     if ( 1 != function.dimensionality() )
    00138       { throw GaudiException
    00139           ("GaudiMath::Integral: illegal function dimension" ,
    00140            "*GaudiMath*" , StatusCode::FAILURE ); }
    00141
    00142     const Genfun::AbsFunction& one   =
    00143       Genfun::GaudiMathImplementation::Constant ( 1.0 , 1 ) ;
    00144
    00145     const Genfun::AbsFunction& cross =
    00146       Genfun::FunctionDirectProduct (&one , &function ) ;
    00147
    00148     // FIXME: (MCl) the static_cast below are needed to avoid warnings and to
    00149     // match the signature in NumericalDefiniteIntegral.h (around line 288).
    00150     const Genfun::AbsFunction& result =
    00151       Genfun::GaudiMathImplementation::NumericalDefiniteIntegral
    00152       ( cross , 1 , static_cast<float>(epsabs) , static_cast<float>(epsrel) , size ) ;
    00153
    00154     return result( Genfun::Argument(1) ) ;
    00155   }
    00156
    00157
    00158
    00159
    00160
    00161
    00162 }
    00163
    00164
    00165 // ============================================================================
    00166 // The END
    00167 // ============================================================================
    00168