All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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) ;
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:
68  private:
69  const AIDA::IFunction* m_fun ;
70  size_t m_dim ;
72  };
74  FUNCTION_OBJECT_IMP( AdapterIFunction )
75 
76  // ========================================================================
100  // ========================================================================
102  {
103  public:
105  typedef double (*Function)( const double ,
106  const double ) ;
107  public:
109  FUNCTION_OBJECT_DEF( Adapter2DoubleFunction )
110  public:
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
132  // assigmenet operator is disabled
134  private:
136  };
138  FUNCTION_OBJECT_IMP( Adapter2DoubleFunction )
139 
140  // ========================================================================
165  // ========================================================================
167  {
168  public:
170  typedef double (*Function)( const double ,
171  const double ,
172  const double ) ;
173  public:
175  FUNCTION_OBJECT_DEF( Adapter3DoubleFunction )
176  public:
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
200  // assignment operator is disabled
202  private:
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
273 
274  private:
275 
277  size_t m_DIM ;
278 
279  Function1 m_func1 ;
280 
281  Function2 m_func2 ;
283 
284  Function3 m_func3 ;
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 // ============================================================================
unsigned int dimensionality() const override
dimensionality of the problem
Definition: FunAdapters.h:257
bool hasAnalyticDerivative() const override
Does this function have an analytic derivative?
Definition: FunAdapters.h:259
mandatory macro from CLHEP/GenericFunctions
Definition: FunAdapters.h:216
Genfun::AbsFunction Function
Definition: GaudiMath.h:24
#define class
Genfun::GaudiMathImplementation::NumericalDerivative Derivative
Definition: GaudiMath.h:29
bool hasAnalyticDerivative() const override
Does this function have an analytic derivative?
Definition: FunAdapters.h:190
GaudiKernel.
Definition: Fill.h:8
bool hasAnalyticDerivative() const override
Does this function have an analytic derivative?
Definition: FunAdapters.h:124
PropertyMgr & operator=(const PropertyMgr &)=delete
mandatory macro from CLHEP/GenericFunctions
Definition: FunAdapters.h:101
mandatory macro from CLHEP/GenericFunctions
Definition: FunAdapters.h:166
virtual Out operator()(const vector_of_const_< In > &inputs) const =0
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:26
CLHEP.
Definition: IEqSolver.h:13
Genfun::GaudiMathImplementation::SimpleFunction SimpleFunction
Definition: Adapters.h:22
#define GAUDI_API
Definition: Kernel.h:107
unsigned int dimensionality() const override
Definition: FunAdapters.h:58
bool hasAnalyticDerivative() const override
Does this function have an analytic derivative?
Definition: FunAdapters.h:61
constructor from the IFunction ( see AIDA/IFunction.h)
Definition: FunAdapters.h:39