| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

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

- File List
- File Members

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