All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
NumericalDerivative.h
Go to the documentation of this file.
1 #ifndef GAUDIMATH_NUMERICALDERIVATIVE_H
2 #define GAUDIMATH_NUMERICALDERIVATIVE_H 1
3 // ============================================================================
4 // Include files
5 // ============================================================================
6 // GaudiKernel
7 // ============================================================================
9 // ============================================================================
10 // CLHEP
11 // ============================================================================
12 #include "CLHEP/GenericFunctions/AbsFunction.hh"
13 // ============================================================================
14 
15 #if defined(__clang__) || defined(__CLING__)
16 #pragma clang diagnostic push
17 #pragma clang diagnostic ignored "-Winconsistent-missing-override"
18 #elif defined(__GNUC__) && __GNUC__ >= 5
19 #pragma GCC diagnostic push
20 #pragma GCC diagnostic ignored "-Wsuggest-override"
21 #endif
22 
23 namespace Genfun
24 {
25  namespace GaudiMathImplementation
26  {
42  class GAUDI_API NumericalDerivative : public AbsFunction
43  {
44  public:
46  enum Type
47  { Central ,
49  Backward } ;
50  public:
52  FUNCTION_OBJECT_DEF( NumericalDerivative )
53 
54  public:
55 
92  ( const AbsFunction& function ,
93  const size_t index ,
94  const Type& type = Central ) ;
95 
98  ( const NumericalDerivative& right ) ;
99 
101  ~NumericalDerivative () override = default;
102 
104  unsigned int dimensionality() const override { return m_DIM ; }
105 
107  double operator() ( double argument ) const override ;
109  double operator() ( const Argument& argument ) const override ;
110 
112  bool hasAnalyticDerivative() const override { return true ;}
113 
115  Derivative partial ( unsigned int index ) const override;
116 
117  public:
118 
120  const AbsFunction& function () const { return *m_function ; }
122  size_t index () const { return m_index ; }
124  const Type& type () const { return m_type ; }
125 
127  const Type& setType ( const Type& value );
128 
130  double result () const { return m_result ; }
132  double error () const { return m_error ; }
133 
134  protected:
135 
136  StatusCode Exception
137  ( const std::string& message ,
138  const StatusCode& sc = StatusCode::FAILURE ) const ;
139 
140  private:
141 
142  // default constructor is disabled
144  // assignement operator is disabled
146 
147  private:
149  size_t m_index ;
150  size_t m_DIM ;
152  //
153  mutable Argument m_argument ;
154  mutable double m_result ;
155  mutable double m_error ;
156  };
158  FUNCTION_OBJECT_IMP( NumericalDerivative )
159 
160  } // end of namespace GaudiMathImplementation
161 } // end of namespace GenFun
162 
163 #if defined(__clang__) || defined(__CLING__)
164 #pragma clang diagnostic pop
165 #elif defined(__GNUC__) && __GNUC__ >= 5
166 #pragma GCC diagnostic pop
167 #endif
168 
169 // ============================================================================
170 // The END
171 // ============================================================================
172 #endif // GAUDIMATH_NUMERICALDERIVATIVE_H
173 // ============================================================================
bool hasAnalyticDerivative() const override
Does this function have an analytic derivative?
double error() const
the absolute error estimate for the last call
Genfun::GaudiMathImplementation::NumericalDerivative Derivative
Definition: GaudiMath.h:29
PropertyMgr & operator=(const PropertyMgr &)=delete
STL class.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Numerical derivative (using GSL adaptive numerical differentiation)
virtual Out operator()(const vector_of_const_< In > &inputs) const =0
CLHEP.
Definition: IEqSolver.h:13
#define GAUDI_API
Definition: Kernel.h:107
double result() const
the result of the last call