| # 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
FunAdapters.h
Go to the documentation of this file.
1 // $Id: FunAdapters.h,v 1.2 2005/11/25 10:27:03 mato Exp $
2 // ============================================================================
3 #ifndef GAUDIMATH_FUNADAPTERS_H
4 #define GAUDIMATH_FUNADAPTERS_H 1
5 // ============================================================================
6 // Include files
7 // ============================================================================
8 // from CLHEP
9 // ============================================================================
10 #include "CLHEP/GenericFunctions/GenericFunctions.hh"
11 #include "CLHEP/GenericFunctions/Argument.hh"
12 #include "CLHEP/GenericFunctions/AbsFunction.hh"
13 // ============================================================================
14 #include "GaudiKernel/Kernel.h"
15
16 namespace AIDA { class IFunction ; }
17
18 namespace Genfun
19 {
20 namespace GaudiMathImplementation
21 {
22 // ========================================================================
29 // =========================================================================
30
31 class GAUDI_API AdapterIFunction : public AbsFunction
32 {
33 public:
35 FUNCTION_OBJECT_DEF( AdapterIFunction )
36 public:
40 AdapterIFunction ( const AIDA::IFunction& fun) ;
42 AdapterIFunction ( const AdapterIFunction& );
44 virtual ~AdapterIFunction() ;
45
46 virtual double operator() ( double a ) const ;
47
48 virtual double operator() ( const Argument& x ) const;
49
50 virtual unsigned int dimensionality () const { return m_dim ; }
51
53 virtual bool hasAnalyticDerivative() const { return true ; }
55 virtual Genfun::Derivative partial( unsigned int i ) const ;
56
57 private:
58 AdapterIFunction();
59 AdapterIFunction& operator=(const AdapterIFunction&);
60 private:
61 const AIDA::IFunction* m_fun ;
62 size_t m_dim ;
63 mutable std::vector<double> m_arg ;
64 };
65
66 // ========================================================================
90 // ========================================================================
91 class GAUDI_API Adapter2DoubleFunction : public AbsFunction
92 {
93 public:
95 typedef double (*Function)( const double ,
96 const double ) ;
97 public:
99 FUNCTION_OBJECT_DEF( Adapter2DoubleFunction )
100 public:
102 Adapter2DoubleFunction ( Function func );
104 Adapter2DoubleFunction ( const Adapter2DoubleFunction& );
106 virtual ~Adapter2DoubleFunction () ;
107
108 virtual double operator() ( double x ) const ;
109
110 virtual double operator() ( const Argument& x ) const ;
111
112 virtual unsigned int dimensionality() const { return 2 ; }
114 virtual bool hasAnalyticDerivative() const { return true ; }
116 virtual Genfun::Derivative partial( unsigned int i ) const ;
117 public:
118 double operator() ( const double x , const double y ) const ;
119 private:
120 // default constructor is disabled
121 Adapter2DoubleFunction();
122 // assigmenet operator is disabled
123 Adapter2DoubleFunction& operator = ( const Adapter2DoubleFunction&);
124 private:
125 Function m_func ;
126 };
127
128 // ========================================================================
153 // ========================================================================
154 class GAUDI_API Adapter3DoubleFunction : public AbsFunction
155 {
156 public:
158 typedef double (*Function)( const double ,
159 const double ,
160 const double ) ;
161 public:
163 FUNCTION_OBJECT_DEF( Adapter3DoubleFunction )
164 public:
166 Adapter3DoubleFunction ( Function func );
168 Adapter3DoubleFunction ( const Adapter3DoubleFunction& );
170 virtual ~Adapter3DoubleFunction () ;
171
172 virtual double operator() ( double x ) const ;
173
174 virtual double operator() ( const Argument& x ) const ;
175
176 virtual unsigned int dimensionality() const { return 3 ; }
178 virtual bool hasAnalyticDerivative() const { return true ; }
180 virtual Genfun::Derivative partial( unsigned int i ) const ;
181 public:
182 double operator() ( const double x ,
183 const double y ,
184 const double z ) const ;
185 private:
186 // default constructor is disabled
187 Adapter3DoubleFunction();
188 // assignment operator is disabled
189 Adapter3DoubleFunction& operator = ( const Adapter3DoubleFunction&);
190 private:
191 Function m_func ;
192 };
193
194 // ========================================================================
201 // ========================================================================
202 class GAUDI_API SimpleFunction : public AbsFunction
203 {
204 public:
205 typedef double (*Function1)( const double ) ;
206 typedef double (*Function2)( const double* ) ;
207 typedef double (*Function3)( const std::vector<double>& ) ;
208 protected:
209 enum Case { TrivialArg , ArrayArg , VectorArg } ;
210 public:
212 FUNCTION_OBJECT_DEF( SimpleFunction )
213
214 public:
215
219 SimpleFunction ( Function1 func ) ;
220
225 SimpleFunction ( Function2 func ,
226 const size_t dim ) ;
227
232 SimpleFunction ( Function3 func ,
233 const size_t dim ) ;
234
236 SimpleFunction ( const SimpleFunction& ) ;
237
238 // destructor
239 virtual ~SimpleFunction();
240 public:
241
243 virtual unsigned int dimensionality () const { return m_DIM ; }
245 virtual bool hasAnalyticDerivative () const { return true ; }
247 virtual double operator() ( double ) const ;
249 virtual double operator() ( const Argument& ) const ;
251 virtual Genfun::Derivative partial ( unsigned int i ) const ;
252
253 private:
254
255 // the default constructor is disabled
256 SimpleFunction() ;
257 // the assignment operator is disabled
258 SimpleFunction& operator=(const SimpleFunction& );
259
260 private:
261
262 Case m_case ;
263 size_t m_DIM ;
264
265 Function1 m_func1 ;
266
267 Function2 m_func2 ;
268 double* m_arg2 ;
269
270 Function3 m_func3 ;
271 mutable std::vector<double> m_arg3 ;
272 };
273
274 } // end of namespace GaudiMathImeplementation
275 } // end of namespace Genfun
276
277
278 #endif // GAUDIMATH_FUNADAPTERS_H
279 // ============================================================================