| The Gaudi Framework v28r2p1 (f1a77ff4)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

Integral1Test.cpp
Go to the documentation of this file.
1 // ============================================================================
2 // Include files
3 // ============================================================================
4 // STD & STL
5 // ============================================================================
6 #include <math.h>
7 #include <stdio.h>
8 // ============================================================================
9 // GaudiMath
10 // ============================================================================
11 #include "GaudiMath/Integral.h"
12 #include "GaudiMath/GaudiMath.h"
13 #include "GaudiKernel/SystemOfUnits.h"
14 // ============================================================================
15 // CLHEP
16 // ============================================================================
17 #include "CLHEP/GenericFunctions/Sin.hh"
18 #include "CLHEP/GenericFunctions/Cos.hh"
19 #include "CLHEP/GenericFunctions/Gaussian.hh"
20 // ============================================================================
21 // Handle CLHEP 2.0.x move to CLHEP namespace
22 namespace CLHEP { }
23 using namespace CLHEP;
24
25 // ============================================================================
33 // ============================================================================
34
35 int main()
36 {
37
38 std::cout <<
39 " Test for numerical integration of Genfun::Sin(x) " << std::endl ;
40
41 const GaudiMath::Function& mysin = Genfun::Sin();
42
43
44 for( double x = 0 * Gaudi::Units::degree ;
45 x <= 360 * Gaudi::Units::degree ;
46 x += 15 * Gaudi::Units::degree ) {
47 double value = GaudiMath::Integral ( mysin , 0. , x ) ;
48 printf( "x=%8.3f deg; I(Sin)=%+.19f; ActErr=%+.19f;\n",
49 x / Gaudi::Units::degree , value , value-(1-cos(x)) );
50 }
51
52
53 const GaudiMath::Function& myfun = Genfun::Gaussian();
54
55 std::cout
56 << " integral from gauss1 = "
57 << GaudiMath::Integral( myfun , 0.0 , GaudiMath::Integration::Infinity )
58 << std::endl << " integral from gauss2 = "
59 << GaudiMath::Integral( myfun , GaudiMath::Integration::Infinity ,0.0 )
60 << std::endl << " integral from gauss3 = "
61 << GaudiMath::Integral( myfun ,
62 GaudiMath::Integration::Infinity ,
63 GaudiMath::Integration::Infinity )
64 << std::endl << " integral from gauss4 = "
65 << GaudiMath::Integral( myfun , GaudiMath::Integration::Infinity , 1.0 )
66 << std::endl << " integral from gauss5 = "
67 << GaudiMath::Integral( myfun , GaudiMath::Integration::Infinity , 4.0 )
68 << std::endl << " integral from gauss6 = "
69 << GaudiMath::Integral( myfun , GaudiMath::Integration::Infinity , 9.0 )
70 << std::endl << " integral from gauss7 = "
71 << GaudiMath::Integral( myfun , GaudiMath::Integration::Infinity , 16.0 )
72 << std::endl << " integral from gauss8 = "
73 << GaudiMath::Integral( myfun , GaudiMath::Integration::Infinity , 25.0 )
74 << std::endl ;
75
76
77 exit(0);
78 }
79
80 // ============================================================================
81 // The END
82 // ============================================================================
Gaudi::Units::degree
constexpr double degree
Definition: SystemOfUnits.h:108
std::endl
T endl(T...args)
GaudiMath::Integration::Infinity
Definition: Integration.h:20
GaudiMath::Function
Genfun::AbsFunction Function
Definition: GaudiMath.h:24
main
int main()
Definition: Integral1Test.cpp:35
CLHEP
Definition: IFuncMinimum.h:16
Integral.h
GaudiMath::Integral
GAUDI_API double Integral(const Genfun::AbsFunction &function, const double a, const double b, const GaudiMath::Integration::Type type=GaudiMath::Integration::Adaptive, const GaudiMath::Integration::KronrodRule rule=GaudiMath::Integration::Default, const double epsabs=1.e-10, const double epsrel=1.e-7, const size_t size=1000)
Definition: Integral.cpp:27
SystemOfUnits.h
std::cout
GaudiMath.h