Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:54:35

0001 // -*- C++ -*-
0002 // $Id: FunctionNumDeriv.hh,v 1.2 2003/09/06 14:04:13 boudreau Exp $
0003 //--------------------------FunctionNumDeriv--------------------------------//
0004 //                                                                          //
0005 // Class FunctionNumDeriv, providing numerical derivatives                  //
0006 // Joe Boudreau, Mark Fischler, February 2001                               //
0007 //                                                                          //
0008 //--------------------------------------------------------------------------//
0009 #ifndef FunctionNumDeriv_h
0010 #define FunctionNumDeriv_h 1
0011 #include "CLHEP/GenericFunctions/AbsFunction.hh"
0012 
0013 namespace Genfun {
0014 
0015   /**
0016    * @author
0017    * @ingroup genfun
0018    */
0019   class FunctionNumDeriv : public AbsFunction {
0020   
0021     FUNCTION_OBJECT_DEF(FunctionNumDeriv)
0022 
0023       public:
0024 
0025     // Constructor
0026     FunctionNumDeriv(const AbsFunction *arg1, unsigned int index=0);
0027   
0028     // Copy constructor.
0029     FunctionNumDeriv(const FunctionNumDeriv &right);
0030   
0031     // Destructor
0032     virtual ~FunctionNumDeriv();
0033   
0034     // Retreive function value
0035     virtual double operator ()(double argument) const override;
0036     virtual double operator ()(const Argument & a) const override;
0037   
0038     // Dimensionality 
0039     virtual unsigned int dimensionality() const override;
0040 
0041   private:
0042   
0043     // It is illegal to assign a FunctionNumDeriv
0044     const FunctionNumDeriv & operator=(const FunctionNumDeriv &right);
0045 
0046     // The function we're differntiating.
0047     const AbsFunction        *_arg1;
0048     const unsigned int       _wrtIndex;
0049 
0050     // helper data and methods to let us code Argument and double similarly
0051     double numericalDerivative 
0052     ( double (FunctionNumDeriv::*f)(double)const, double x ) const;
0053     double f_x   (double x) const;
0054     double f_Arg (double x) const;
0055     mutable Argument        _xArg;
0056 
0057   };
0058 } // namespace Genfun
0059 #endif