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 // ============================================================================
8 // ============================================================================
9 // GaudiMath
10 // ============================================================================
11 #include "GaudiMath/Integral.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 ,
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 =
44 
45  const Genfun::AbsFunction& cross =
46  Genfun::FunctionDirectProduct (&one , &function ) ;
47 
48  const Genfun::AbsFunction& result =
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 =
72 
73  const Genfun::AbsFunction& cross =
74  Genfun::FunctionDirectProduct (&one , &function ) ;
75 
76  const Genfun::AbsFunction& result =
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 ,
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 =
98 
99  const Genfun::AbsFunction& cross =
100  Genfun::FunctionDirectProduct (&one , &function ) ;
101 
102  const Genfun::AbsFunction& result =
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 ,
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 =
124 
125  const Genfun::AbsFunction& cross =
126  Genfun::FunctionDirectProduct (&one , &function ) ;
127 
128  const Genfun::AbsFunction& result =
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 =
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 =
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 // ============================================================================
Define general base for Gaudi exception.
string type
Definition: gaudirun.py:126
Type
type of integration (for finite limits)
Definition: Integration.h:27
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:28
KronrodRule
integration rule
Definition: Integration.h:36
Genfun::GaudiMathImplementation::Constant Constant
Definition: GaudiMath.h:29
This class allows the numerical evaluation of the following functions: