All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Integral.cpp
Go to the documentation of this file.
1 // ============================================================================
2 // Include files
3 // ============================================================================
4 // GaudiKernel
5 // ============================================================================
7 // ============================================================================
8 // GaudiMath
9 // ============================================================================
10 #include "GaudiMath/Integral.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 ,
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 =
43 
44  const Genfun::AbsFunction& cross =
45  Genfun::FunctionDirectProduct (&one , &function ) ;
46 
47  const Genfun::AbsFunction& result =
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 =
71 
72  const Genfun::AbsFunction& cross =
73  Genfun::FunctionDirectProduct (&one , &function ) ;
74 
75  const Genfun::AbsFunction& result =
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 ,
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 =
97 
98  const Genfun::AbsFunction& cross =
99  Genfun::FunctionDirectProduct (&one , &function ) ;
100 
101  const Genfun::AbsFunction& result =
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 ,
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 =
123 
124  const Genfun::AbsFunction& cross =
125  Genfun::FunctionDirectProduct (&one , &function ) ;
126 
127  const Genfun::AbsFunction& result =
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 =
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 =
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 // ============================================================================
Define general base for Gaudi exception.
Type
type of integration (for finite limits)
Definition: Integration.h:25
GaudiMath.h GaudiMath/GaudiMath.h.
Definition: Adapters.h:13
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
KronrodRule
integration rule
Definition: Integration.h:34
Genfun::GaudiMathImplementation::Constant Constant
Definition: GaudiMath.h:27
This class allows the numerical evaluation of the following functions: