| The Gaudi Framework v28r2p1 (f1a77ff4)

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

- File List
- File Members

Integral.cpp
Go to the documentation of this file.
1 // ============================================================================
2 // Include files
3 // ============================================================================
4 // GaudiKernel
5 // ============================================================================
6 #include "GaudiKernel/GaudiException.h"
7 // ============================================================================
8 // GaudiMath
9 // ============================================================================
10 #include "GaudiMath/Integral.h"
11 #include "GaudiMath/NumericalDefiniteIntegral.h"
12 #include "GaudiMath/Constant.h"
13 // ============================================================================
14
15 #ifdef __ICC
16 // disable icc remark #1572: floating-point equality and inequality comparisons are unreliable
17 // The comparison are meant
18 #pragma warning(disable:1572)
19 // disable icc remark #2259: non-pointer conversion from "double" to "float" may lose significant bits
20 #pragma warning(disable:2259)
21 #endif
22
23 namespace GaudiMath
24 {
25
26 double Integral
27 ( const Genfun::AbsFunction& function ,
28 const double a ,
29 const double b ,
30 const GaudiMath::Integration::Type type ,
31 const GaudiMath::Integration::KronrodRule rule ,
32 const double epsabs ,
33 const double epsrel ,
34 const size_t size )
35 {
36 if ( 1 != function.dimensionality() )
37 { throw GaudiException
38 ("GaudiMath::Integral: illegal function dimension" ,
39 "*GaudiMath*" , StatusCode::FAILURE ); }
40
41 const Genfun::AbsFunction& one =
42 Genfun::GaudiMathImplementation::Constant ( 1.0 , 1 ) ;
43
44 const Genfun::AbsFunction& cross =
45 Genfun::FunctionDirectProduct (&one , &function ) ;
46
47 const Genfun::AbsFunction& result =
48 Genfun::GaudiMathImplementation::NumericalDefiniteIntegral
49 ( cross , 1 , a , b, type , rule , epsabs , epsrel , size ) ;
50
51 return result( Genfun::Argument(1) ) ;
52 }
53
54 double Integral
55 ( const Genfun::AbsFunction& function ,
56 const double a ,
57 const double b ,
58 const std::vector<double>& points ,
59 const double epsabs ,
60 const double epsrel ,
61 const size_t size )
62 {
63
64 if ( 1 != function.dimensionality() )
65 { throw GaudiException
66 ("GaudiMath::Integral: illegal function dimension" ,
67 "*GaudiMath*" , StatusCode::FAILURE ); }
68
69 const Genfun::AbsFunction& one =
70 Genfun::GaudiMathImplementation::Constant ( 1.0 , 1 ) ;
71
72 const Genfun::AbsFunction& cross =
73 Genfun::FunctionDirectProduct (&one , &function ) ;
74
75 const Genfun::AbsFunction& result =
76 Genfun::GaudiMathImplementation::NumericalDefiniteIntegral
77 ( cross , 1 , a , b, points , epsabs , epsrel , size ) ;
78
79 return result( Genfun::Argument(1) ) ;
80 }
81
82 double Integral
83 ( const Genfun::AbsFunction& function ,
84 const double a ,
85 const GaudiMath::Integration::Inf b ,
86 const double epsabs ,
87 const double epsrel ,
88 const size_t size )
89 {
90 if ( 1 != function.dimensionality() )
91 { throw GaudiException
92 ("GaudiMath::Integral: illegal function dimension" ,
93 "*GaudiMath*" , StatusCode::FAILURE ); }
94
95 const Genfun::AbsFunction& one =
96 Genfun::GaudiMathImplementation::Constant ( 1.0 , 1 ) ;
97
98 const Genfun::AbsFunction& cross =
99 Genfun::FunctionDirectProduct (&one , &function ) ;
100
101 const Genfun::AbsFunction& result =
102 Genfun::GaudiMathImplementation::NumericalDefiniteIntegral
103 ( cross , 1 , a , b , epsabs , epsrel , size ) ;
104
105 return result( Genfun::Argument(1) ) ;
106 }
107
108 double Integral
109 ( const Genfun::AbsFunction& function ,
110 const GaudiMath::Integration::Inf a ,
111 const double b ,
112 const double epsabs ,
113 const double epsrel ,
114 const size_t size )
115 {
116 if ( 1 != function.dimensionality() )
117 { throw GaudiException
118 ("GaudiMath::Integral: illegal function dimension" ,
119 "*GaudiMath*" , StatusCode::FAILURE ); }
120
121 const Genfun::AbsFunction& one =
122 Genfun::GaudiMathImplementation::Constant ( 1.0 , 1 ) ;
123
124 const Genfun::AbsFunction& cross =
125 Genfun::FunctionDirectProduct (&one , &function ) ;
126
127 const Genfun::AbsFunction& result =
128 Genfun::GaudiMathImplementation::NumericalDefiniteIntegral
129 ( cross , 1 , a , b , epsabs , epsrel , size ) ;
130
131 return result( Genfun::Argument(1) ) ;
132 }
133
134
135
136 double Integral
137 ( const Genfun::AbsFunction& function ,
138 const GaudiMath::Integration::Inf /* a */ ,
139 const GaudiMath::Integration::Inf /* b */ ,
140 const double epsabs ,
141 const double epsrel ,
142 const size_t size )
143 {
144 if ( 1 != function.dimensionality() )
145 { throw GaudiException
146 ("GaudiMath::Integral: illegal function dimension" ,
147 "*GaudiMath*" , StatusCode::FAILURE ); }
148
149 const Genfun::AbsFunction& one =
150 Genfun::GaudiMathImplementation::Constant ( 1.0 , 1 ) ;
151
152 const Genfun::AbsFunction& cross =
153 Genfun::FunctionDirectProduct (&one , &function ) ;
154
155 // FIXME: (MCl) the static_cast below are needed to avoid warnings and to
156 // match the signature in NumericalDefiniteIntegral.h (around line 288).
157 const Genfun::AbsFunction& result =
158 Genfun::GaudiMathImplementation::NumericalDefiniteIntegral
159 ( cross , 1 , static_cast<float>(epsabs) , static_cast<float>(epsrel) , size ) ;
160
161 return result( Genfun::Argument(1) ) ;
162 }
163
164 }
165
166 // ============================================================================
167 // The END
168 // ============================================================================
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:23
StatusCode::FAILURE
Definition: StatusCode.h:29
GaudiMath::Integration::Inf
Inf
infinity
Definition: Integration.h:20
NumericalDefiniteIntegral.h
GaudiMath::Integration::Type
Type
type of integration (for finite limits)
Definition: Integration.h:25
GaudiException.h
gaudirun.type
type
Definition: gaudirun.py:125
std::vector< double >
Constant.h
Integral.h
GaudiMath
GaudiMath.h GaudiMath/GaudiMath.h.
Definition: Adapters.h:13
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
GaudiMath::Integration::KronrodRule
KronrodRule
integration rule
Definition: Integration.h:34
GaudiMath::Constant
Genfun::GaudiMathImplementation::Constant Constant
Definition: GaudiMath.h:27
Genfun::GaudiMathImplementation::NumericalDefiniteIntegral
This class allows the numerical evaluation of the following functions:
Definition: NumericalDefiniteIntegral.h:79