The Gaudi Framework  v28r3 (cc1cf868)
Integral1Test.cpp
Go to the documentation of this file.
1 // ============================================================================
2 // Include files
3 // ============================================================================
4 // STD & STL
5 // ============================================================================
6 #include <cmath>
7 #include <cstdio>
8 // ============================================================================
9 // GaudiMath
10 // ============================================================================
11 #include "GaudiMath/Integral.h"
12 #include "GaudiMath/GaudiMath.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  for( double x = 0 * Gaudi::Units::degree ;
44  x <= 360 * Gaudi::Units::degree ;
45  x += 15 * Gaudi::Units::degree ) {
46  double value = GaudiMath::Integral ( mysin , 0. , x ) ;
47  printf( "x=%8.3f deg; I(Sin)=%+.19f; ActErr=%+.19f;\n",
48  x / Gaudi::Units::degree , value , value-(1-cos(x)) );
49  }
50 
51  const GaudiMath::Function& myfun = Genfun::Gaussian();
52 
53  std::cout
54  << " integral from gauss1 = "
56  << "\n integral from gauss2 = "
58  << "\n integral from gauss3 = "
59  << GaudiMath::Integral( myfun ,
62  << "\n integral from gauss4 = "
64  << "\n integral from gauss5 = "
66  << "\n integral from gauss6 = "
68  << "\n integral from gauss7 = "
70  << "\n integral from gauss8 = "
72  << "\n";
73 
74 }
75 
76 // ============================================================================
77 // The END
78 // ============================================================================
constexpr double degree
T endl(T...args)
Genfun::AbsFunction Function
Definition: GaudiMath.h:24
int main()
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