Gaudi Framework, version v22r0

Home   Generated: 9 Feb 2011

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

Generated at Wed Feb 9 16:24:49 2011 for Gaudi Framework, version v22r0 by Doxygen version 1.6.2 written by Dimitri van Heesch, © 1997-2004