CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

F1D.hh

Go to the documentation of this file.
00001 // -*- C++ -*------------------------------------------------------
00002 //
00003 // This class is an adaptor from any function (double *f)(double x)
00004 // of one real variable, to generic functions. This allows one
00005 // to plot, differentiate, sum, compose, etc, any standard C or
00006 // C++ math function by converting it to a Generic Function.
00007 //
00008 // Joe Boudreau October 2012
00009 //-----------------------------------------------------
00010 #ifndef F1D_h
00011 #define F1D_h 1
00012 #include "CLHEP/GenericFunctions/AbsFunction.hh"
00013 namespace Genfun {
00014 
00019   class F1D : public AbsFunction  {
00020     
00021     typedef double (*FcnPtr)(double);
00022 
00023     FUNCTION_OBJECT_DEF(F1D)
00024 
00025       public:
00026 
00027     // Constructor
00028     F1D(FcnPtr fcn):p(fcn){};
00029 
00030     // Destructor
00031     virtual ~F1D(){};
00032   
00033     // Copy constructor
00034     F1D(const F1D &right):AbsFunction(),p(right.p){};
00035   
00036     // Retreive function value
00037     virtual double operator ()(double x) const {
00038       return (*p)(x);
00039     }
00040 
00041     virtual double operator ()(const Argument & a) const {return operator() (a[0]);}
00042 
00043   private:
00044 
00045     // It is illegal to assign a F1D
00046     const F1D & operator=(const F1D &right);
00047 
00048     // Data:
00049     FcnPtr p;
00050 
00051   };
00052   FUNCTION_OBJECT_IMP(F1D)
00053 } // namespace Genfun
00054 #endif

Generated on 15 Nov 2012 for CLHEP by  doxygen 1.4.7