GeoModel - GeoModelCore
FunctionNumDeriv.h
1 //==========================================================================//
2 // Imported from the QAT library (qat.pitt.edu) by the copyright holder //
3 // Joe Boudreau. Software licensed under the terms and conditions of the //
4 // GNU Lesser Public License v3. //
5 //==========================================================================//
6 
7 //--------------------------FunctionNumDeriv--------------------------------//
8 // //
9 // Class FunctionNumDeriv, providing numerical derivatives //
10 // //
11 //--------------------------------------------------------------------------//
12 #ifndef FunctionNumDeriv_h
13 #define FunctionNumDeriv_h 1
14 #include "GeoGenericFunctions/AbsFunction.h"
15 
16 namespace GeoGenfun {
17 
18  class FunctionNumDeriv : public AbsFunction {
19 
20  FUNCTION_OBJECT_DEF(FunctionNumDeriv)
21 
22  public:
23 
24  // Constructor
25  FunctionNumDeriv(const AbsFunction *arg1, unsigned int index=0);
26 
27  // Copy constructor.
28  FunctionNumDeriv(const FunctionNumDeriv &right);
29 
30  // Destructor
31  virtual ~FunctionNumDeriv();
32 
33  // Retreive function value
34  virtual double operator ()(double argument) const override;
35  virtual double operator ()(const Argument & a) const override;
36 
37  // Dimensionality
38  virtual unsigned int dimensionality() const override;
39 
40  private:
41 
42  // It is illegal to assign a FunctionNumDeriv
43  const FunctionNumDeriv & operator=(const FunctionNumDeriv &right);
44 
45  // The function we're differntiating.
46  const AbsFunction *_arg1;
47  const unsigned int _wrtIndex;
48 
49  // helper data and methods to let us code Argument and double similarly
50  double numericalDerivative
51  ( double (FunctionNumDeriv::*f)(double)const, double x ) const;
52  double f_x (double x) const;
53  double f_Arg (double x) const;
54  mutable Argument _xArg;
55 
56  };
57 } // namespace GeoGenfun
58 #endif
Definition: Abs.h:15