| The Gaudi Framework v28r2-patches (bc4ad17a)

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

- File List
- File Members

FunAdapters.h
Go to the documentation of this file.
1 #ifndef GAUDIMATH_FUNADAPTERS_H
2 #define GAUDIMATH_FUNADAPTERS_H 1
3 // ============================================================================
4 // Include files
5 // ============================================================================
6 #include <memory>
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 #if defined(__clang__) || defined(__CLING__)
17 #pragma clang diagnostic push
18 #pragma clang diagnostic ignored "-Winconsistent-missing-override"
19 #elif defined(__GNUC__) && __GNUC__ >= 5
20 #pragma GCC diagnostic push
21 #pragma GCC diagnostic ignored "-Wsuggest-override"
22 #endif
23
24 namespace AIDA { class IFunction ; }
25
26 namespace Genfun
27 {
28 namespace GaudiMathImplementation
29 {
30 // ========================================================================
37 // =========================================================================
38
39 class GAUDI_API AdapterIFunction : public AbsFunction
40 {
41 public:
43 FUNCTION_OBJECT_DEF( AdapterIFunction )
44 public:
48 AdapterIFunction ( const AIDA::IFunction& fun) ;
50 AdapterIFunction ( const AdapterIFunction& );
52 ~AdapterIFunction() override;
53
54 double operator() ( double a ) const override;
55
56 double operator() ( const Argument& x ) const override;
57
58 unsigned int dimensionality () const override { return m_dim ; }
59
61 bool hasAnalyticDerivative() const override { return true ; }
63 Genfun::Derivative partial( unsigned int i ) const override;
64
65 private:
66 AdapterIFunction();
67 AdapterIFunction& operator=(const AdapterIFunction&);
68 private:
69 const AIDA::IFunction* m_fun ;
70 size_t m_dim ;
71 mutable std::vector<double> m_arg ;
72 };
74 FUNCTION_OBJECT_IMP( AdapterIFunction )
75
76 // ========================================================================
100 // ========================================================================
101 class GAUDI_API Adapter2DoubleFunction : public AbsFunction
102 {
103 public:
105 typedef double (*Function)( const double ,
106 const double ) ;
107 public:
109 FUNCTION_OBJECT_DEF( Adapter2DoubleFunction )
110 public:
112 Adapter2DoubleFunction ( Function func );
114 Adapter2DoubleFunction ( const Adapter2DoubleFunction& );
116 ~Adapter2DoubleFunction () override;
117
118 double operator() ( double x ) const override;
119
120 double operator() ( const Argument& x ) const override;
121
122 unsigned int dimensionality() const override { return 2 ; }
124 bool hasAnalyticDerivative() const override { return true ; }
126 Genfun::Derivative partial( unsigned int i ) const override;
127 public:
128 double operator() ( const double x , const double y ) const ;
129 private:
130 // default constructor is disabled
131 Adapter2DoubleFunction();
132 // assigmenet operator is disabled
133 Adapter2DoubleFunction& operator = ( const Adapter2DoubleFunction&);
134 private:
135 Function m_func ;
136 };
138 FUNCTION_OBJECT_IMP( Adapter2DoubleFunction )
139
140 // ========================================================================
165 // ========================================================================
166 class GAUDI_API Adapter3DoubleFunction : public AbsFunction
167 {
168 public:
170 typedef double (*Function)( const double ,
171 const double ,
172 const double ) ;
173 public:
175 FUNCTION_OBJECT_DEF( Adapter3DoubleFunction )
176 public:
178 Adapter3DoubleFunction ( Function func );
180 Adapter3DoubleFunction ( const Adapter3DoubleFunction& );
182 ~Adapter3DoubleFunction () override ;
183
184 double operator() ( double x ) const override ;
185
186 double operator() ( const Argument& x ) const override ;
187
188 unsigned int dimensionality() const override { return 3 ; }
190 bool hasAnalyticDerivative() const override { return true ; }
192 Genfun::Derivative partial( unsigned int i ) const override ;
193 public:
194 double operator() ( const double x ,
195 const double y ,
196 const double z ) const ;
197 private:
198 // default constructor is disabled
199 Adapter3DoubleFunction();
200 // assignment operator is disabled
201 Adapter3DoubleFunction& operator = ( const Adapter3DoubleFunction&);
202 private:
203 Function m_func ;
204 };
206 FUNCTION_OBJECT_IMP( Adapter3DoubleFunction )
207
208 // ========================================================================
215 // ========================================================================
216 class GAUDI_API SimpleFunction : public AbsFunction
217 {
218 public:
219 typedef double (*Function1)( const double ) ;
220 typedef double (*Function2)( const double* ) ;
221 typedef double (*Function3)( const std::vector<double>& ) ;
222 protected:
223 enum Case { TrivialArg , ArrayArg , VectorArg } ;
224 public:
226 FUNCTION_OBJECT_DEF( SimpleFunction )
227
228 public:
229
233 SimpleFunction ( Function1 func ) ;
234
239 SimpleFunction ( Function2 func ,
240 const size_t dim ) ;
241
246 SimpleFunction ( Function3 func ,
247 const size_t dim ) ;
248
250 SimpleFunction ( const SimpleFunction& ) ;
251
252 // destructor
253 ~SimpleFunction() override = default;
254 public:
255
257 unsigned int dimensionality () const override { return m_DIM ; }
259 bool hasAnalyticDerivative () const override { return true ; }
261 double operator() ( double ) const override ;
263 double operator() ( const Argument& ) const override ;
265 Genfun::Derivative partial ( unsigned int i ) const override ;
266
267 private:
268
269 // the default constructor is disabled
270 SimpleFunction() ;
271 // the assignment operator is disabled
272 SimpleFunction& operator=(const SimpleFunction& );
273
274 private:
275
276 Case m_case ;
277 size_t m_DIM ;
278
279 Function1 m_func1 ;
280
281 Function2 m_func2 ;
282 std::unique_ptr<double[]> m_arg2 ;
283
284 Function3 m_func3 ;
285 mutable std::vector<double> m_arg3 ;
286 };
288 FUNCTION_OBJECT_IMP( SimpleFunction )
289
290 } // end of namespace GaudiMathImeplementation
291 } // end of namespace Genfun
292
293 #if defined(__clang__) || defined(__CLING__)
294 #pragma clang diagnostic pop
295 #elif defined(__GNUC__) && __GNUC__ >= 5
296 #pragma GCC diagnostic pop
297 #endif
298
299 #endif // GAUDIMATH_FUNADAPTERS_H
300 // ============================================================================
Kernel.h
Genfun::GaudiMathImplementation::SimpleFunction::dimensionality
unsigned int dimensionality() const override
dimensionality of the problem
Definition: FunAdapters.h:257
Genfun::GaudiMathImplementation::SimpleFunction::hasAnalyticDerivative
bool hasAnalyticDerivative() const override
Does this function have an analytic derivative?
Definition: FunAdapters.h:259
Genfun::GaudiMathImplementation::SimpleFunction::m_func3
Function3 m_func3
Definition: FunAdapters.h:284
Genfun::GaudiMathImplementation::SimpleFunction::m_arg2
std::unique_ptr< double[]> m_arg2
Definition: FunAdapters.h:282
Genfun::GaudiMathImplementation::SimpleFunction
mandatory macro from CLHEP/GenericFunctions
Definition: FunAdapters.h:216
GaudiMath::Function
Genfun::AbsFunction Function
Definition: GaudiMath.h:24
class
#define class
Definition: HistogramPersistencySvc.cpp:45
GaudiMath::Derivative
Genfun::GaudiMathImplementation::NumericalDerivative Derivative
Definition: GaudiMath.h:29
Genfun::GaudiMathImplementation::Adapter3DoubleFunction::hasAnalyticDerivative
bool hasAnalyticDerivative() const override
Does this function have an analytic derivative?
Definition: FunAdapters.h:190
Genfun::GaudiMathImplementation::AdapterIFunction::m_dim
size_t m_dim
Definition: FunAdapters.h:70
AIDA
GaudiKernel.
Definition: Fill.h:8
Genfun::GaudiMathImplementation::SimpleFunction::m_func2
Function2 m_func2
Definition: FunAdapters.h:281
Genfun::GaudiMathImplementation::Adapter2DoubleFunction::hasAnalyticDerivative
bool hasAnalyticDerivative() const override
Does this function have an analytic derivative?
Definition: FunAdapters.h:124
operator=
PropertyMgr & operator=(const PropertyMgr &)=delete
Genfun::GaudiMathImplementation::Adapter2DoubleFunction
mandatory macro from CLHEP/GenericFunctions
Definition: FunAdapters.h:101
Genfun::GaudiMathImplementation::SimpleFunction::m_arg3
std::vector< double > m_arg3
Definition: FunAdapters.h:285
Genfun::GaudiMathImplementation::Adapter2DoubleFunction::m_func
Function m_func
Definition: FunAdapters.h:135
GaudiPluginService.cpluginsvc.func
func
Definition: cpluginsvc.py:218
Genfun::GaudiMathImplementation::Adapter3DoubleFunction::m_func
Function m_func
Definition: FunAdapters.h:203
Genfun::GaudiMathImplementation::SimpleFunction::Case
Case
Definition: FunAdapters.h:223
Genfun::GaudiMathImplementation::SimpleFunction::m_DIM
size_t m_DIM
Definition: FunAdapters.h:277
Genfun::GaudiMathImplementation::Adapter3DoubleFunction
mandatory macro from CLHEP/GenericFunctions
Definition: FunAdapters.h:166
Genfun::GaudiMathImplementation::AdapterIFunction::m_fun
const AIDA::IFunction * m_fun
Definition: FunAdapters.h:69
std::vector< double >
std::unique_ptr< double[]>
Gaudi::Functional::operator()
virtual Out operator()(const vector_of_const_< In > &inputs) const =0
Genfun::GaudiMathImplementation::SimpleFunction::m_case
Case m_case
Definition: FunAdapters.h:276
Genfun::GaudiMathImplementation::AdapterIFunction::m_arg
std::vector< double > m_arg
Definition: FunAdapters.h:71
fun
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:26
Genfun::GaudiMathImplementation::SimpleFunction::m_func1
Function1 m_func1
Definition: FunAdapters.h:279
Genfun
CLHEP.
Definition: IEqSolver.h:13
GaudiMath::SimpleFunction
Genfun::GaudiMathImplementation::SimpleFunction SimpleFunction
Definition: Adapters.h:22
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:107
Genfun::GaudiMathImplementation::AdapterIFunction::dimensionality
unsigned int dimensionality() const override
Definition: FunAdapters.h:58
Genfun::GaudiMathImplementation::AdapterIFunction::hasAnalyticDerivative
bool hasAnalyticDerivative() const override
Does this function have an analytic derivative?
Definition: FunAdapters.h:61
Genfun::GaudiMathImplementation::AdapterIFunction
constructor from the IFunction ( see AIDA/IFunction.h)
Definition: FunAdapters.h:39