Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 // ============================================================================
12 #include "GaudiMath/GaudiMath.h"
13 #include "GaudiMath/Integral.h"
14 // ============================================================================
15 // CLHEP
16 // ============================================================================
17 #include "CLHEP/GenericFunctions/Cos.hh"
18 #include "CLHEP/GenericFunctions/Gaussian.hh"
19 #include "CLHEP/GenericFunctions/Sin.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  std::cout << " Test for numerical integration of Genfun::Sin(x) " << std::endl;
38 
39  const GaudiMath::Function& mysin = Genfun::Sin();
40 
41  for ( double x = 0 * Gaudi::Units::degree; x <= 360 * Gaudi::Units::degree; x += 15 * Gaudi::Units::degree ) {
42  double value = GaudiMath::Integral( mysin, 0., x );
43  printf( "x=%8.3f deg; I(Sin)=%+.19f; ActErr=%+.19f;\n", x / Gaudi::Units::degree, value, value - ( 1 - cos( x ) ) );
44  }
45 
46  const GaudiMath::Function& myfun = Genfun::Gaussian();
47 
48  std::cout << " integral from gauss1 = " << GaudiMath::Integral( myfun, 0.0, GaudiMath::Integration::Infinity )
49  << "\n integral from gauss2 = " << GaudiMath::Integral( myfun, GaudiMath::Integration::Infinity, 0.0 )
50  << "\n integral from gauss3 = "
52  << "\n integral from gauss4 = " << GaudiMath::Integral( myfun, GaudiMath::Integration::Infinity, 1.0 )
53  << "\n integral from gauss5 = " << GaudiMath::Integral( myfun, GaudiMath::Integration::Infinity, 4.0 )
54  << "\n integral from gauss6 = " << GaudiMath::Integral( myfun, GaudiMath::Integration::Infinity, 9.0 )
55  << "\n integral from gauss7 = " << GaudiMath::Integral( myfun, GaudiMath::Integration::Infinity, 16.0 )
56  << "\n integral from gauss8 = " << GaudiMath::Integral( myfun, GaudiMath::Integration::Infinity, 25.0 )
57  << "\n";
58 }
59 
60 // ============================================================================
61 // The END
62 // ============================================================================
constexpr double degree
T endl(T...args)
Genfun::AbsFunction Function
Definition: GaudiMath.h:23
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:25