| # Gaudi Framework, version v21r10p1 |

Home |  | Generated: 29 Jul 2010

# FunAdapters.h

Go to the documentation of this file.

    00001 // $Id: FunAdapters.h,v 1.2 2005/11/25 10:27:03 mato Exp $
    00002 // ============================================================================
    00003 #ifndef GAUDIMATH_FUNADAPTERS_H
    00004 #define GAUDIMATH_FUNADAPTERS_H 1
    00005 // ============================================================================
    00006 // Include files
    00007 // ============================================================================
    00008 // from CLHEP
    00009 // ============================================================================
    00010 #include "CLHEP/GenericFunctions/GenericFunctions.hh"
    00011 #include "CLHEP/GenericFunctions/Argument.hh"
    00012 #include "CLHEP/GenericFunctions/AbsFunction.hh"
    00013 // ============================================================================
    00014 #include "GaudiKernel/Kernel.h"
    00015
    00016 namespace AIDA { class IFunction ; }
    00017
    00018 namespace Genfun
    00019 {
    00020   namespace GaudiMathImplementation
    00021   {
    00022     // ========================================================================
    00029     // =========================================================================
    00030
    00031     class GAUDI_API AdapterIFunction : public AbsFunction
    00032     {
    00033     public:
    00035       FUNCTION_OBJECT_DEF( AdapterIFunction )
    00036     public:
    00040       AdapterIFunction ( const AIDA::IFunction& fun) ;
    00042       AdapterIFunction ( const AdapterIFunction& );
    00044       virtual ~AdapterIFunction() ;
    00045
    00046       virtual double operator() ( double a          ) const ;
    00047
    00048       virtual double operator() ( const Argument& x ) const;
    00049
    00050       virtual unsigned int dimensionality () const { return m_dim ; }
    00051
    00053       virtual bool  hasAnalyticDerivative() const { return true ; }
    00055       virtual Genfun::Derivative partial( unsigned int i  ) const ;
    00056
    00057     private:
    00058       AdapterIFunction();
    00059       AdapterIFunction& operator=(const AdapterIFunction&);
    00060     private:
    00061       const AIDA::IFunction*      m_fun ;
    00062       size_t                      m_dim ;
    00063       mutable std::vector<double> m_arg ;
    00064     };
    00065
    00066     // ========================================================================
    00090     // ========================================================================
    00091     class GAUDI_API Adapter2DoubleFunction : public AbsFunction
    00092     {
    00093     public:
    00095       typedef double (*Function)( const double ,
    00096                                   const double ) ;
    00097     public:
    00099       FUNCTION_OBJECT_DEF( Adapter2DoubleFunction )
    00100     public:
    00102       Adapter2DoubleFunction ( Function func );
    00104       Adapter2DoubleFunction ( const Adapter2DoubleFunction& );
    00106       virtual ~Adapter2DoubleFunction () ;
    00107
    00108       virtual double operator() (       double    x ) const ;
    00109
    00110       virtual double operator() ( const Argument& x ) const ;
    00111
    00112       virtual unsigned int dimensionality() const { return 2    ; }
    00114       virtual bool  hasAnalyticDerivative() const { return true ; }
    00116       virtual Genfun::Derivative partial( unsigned int i  ) const ;
    00117     public:
    00118       double operator() ( const double x , const double y ) const ;
    00119     private:
    00120       // default constructor is disabled
    00121       Adapter2DoubleFunction();
    00122       // assigmenet operator is disabled
    00123       Adapter2DoubleFunction& operator = ( const Adapter2DoubleFunction&);
    00124     private:
    00125       Function                 m_func  ;
    00126     };
    00127
    00128     // ========================================================================
    00153     // ========================================================================
    00154     class GAUDI_API Adapter3DoubleFunction : public AbsFunction
    00155     {
    00156     public:
    00158       typedef double (*Function)( const double ,
    00159                                   const double ,
    00160                                   const double ) ;
    00161     public:
    00163       FUNCTION_OBJECT_DEF( Adapter3DoubleFunction )
    00164     public:
    00166       Adapter3DoubleFunction ( Function func );
    00168       Adapter3DoubleFunction ( const Adapter3DoubleFunction& );
    00170       virtual ~Adapter3DoubleFunction () ;
    00171
    00172       virtual double operator() (       double    x ) const ;
    00173
    00174       virtual double operator() ( const Argument& x ) const ;
    00175
    00176       virtual unsigned int dimensionality() const { return 3    ; }
    00178       virtual bool  hasAnalyticDerivative() const { return true ; }
    00180       virtual Genfun::Derivative partial( unsigned int i  ) const ;
    00181     public:
    00182       double operator() ( const double x ,
    00183                           const double y ,
    00184                           const double z ) const ;
    00185     private:
    00186       // default constructor is disabled
    00187       Adapter3DoubleFunction();
    00188       // assignment operator is disabled
    00189       Adapter3DoubleFunction& operator = ( const Adapter3DoubleFunction&);
    00190     private:
    00191       Function                 m_func  ;
    00192     };
    00193
    00194     // ========================================================================
    00201     // ========================================================================
    00202     class GAUDI_API SimpleFunction : public AbsFunction
    00203     {
    00204     public:
    00205       typedef double (*Function1)( const double               ) ;
    00206       typedef double (*Function2)( const double*              ) ;
    00207       typedef double (*Function3)( const std::vector<double>& ) ;
    00208     protected:
    00209       enum Case { TrivialArg , ArrayArg , VectorArg } ;
    00210     public:
    00212       FUNCTION_OBJECT_DEF( SimpleFunction )
    00213
    00214     public:
    00215
    00219       SimpleFunction ( Function1 func ) ;
    00220
    00225       SimpleFunction ( Function2    func ,
    00226                        const size_t dim ) ;
    00227
    00232       SimpleFunction ( Function3    func ,
    00233                        const size_t dim ) ;
    00234
    00236       SimpleFunction ( const SimpleFunction& ) ;
    00237
    00238       // destructor
    00239       virtual ~SimpleFunction();
    00240     public:
    00241
    00243       virtual unsigned int dimensionality         () const { return m_DIM   ; }
    00245       virtual bool  hasAnalyticDerivative         () const { return true    ; }
    00247       virtual double             operator()  ( double          ) const ;
    00249       virtual double             operator()  ( const Argument& ) const ;
    00251       virtual Genfun::Derivative partial     ( unsigned int i  ) const ;
    00252
    00253     private:
    00254
    00255       // the default constructor  is disabled
    00256       SimpleFunction() ;
    00257       // the assignment operator is disabled
    00258       SimpleFunction& operator=(const SimpleFunction& );
    00259
    00260     private:
    00261
    00262       Case                         m_case     ;
    00263       size_t                       m_DIM      ;
    00264
    00265       Function1                    m_func1    ;
    00266
    00267       Function2                    m_func2    ;
    00268       double*                      m_arg2     ;
    00269
    00270       Function3                    m_func3    ;
    00271       mutable std::vector<double>  m_arg3     ;
    00272     };
    00273
    00274   } // end of namespace GaudiMathImeplementation
    00275 } // end of namespace Genfun
    00276
    00277
    00278 #endif // GAUDIMATH_FUNADAPTERS_H
    00279 // ============================================================================