The Gaudi Framework  v29r0 (ff2e7097)
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 { Central, Forward, Backward };
47 
48  public:
50  FUNCTION_OBJECT_DEF( NumericalDerivative )
51 
52  public:
88  NumericalDerivative( const AbsFunction& function, const size_t index, const Type& type = Central );
89 
92 
94  ~NumericalDerivative() override = default;
95 
97  unsigned int dimensionality() const override { return m_DIM; }
98 
100  double operator()( double argument ) const override;
102  double operator()( const Argument& argument ) const override;
103 
105  bool hasAnalyticDerivative() const override { return true; }
106 
108  Derivative partial( unsigned int index ) const override;
109 
110  public:
112  const AbsFunction& function() const { return *m_function; }
114  size_t index() const { return m_index; }
116  const Type& type() const { return m_type; }
117 
119  const Type& setType( const Type& value );
120 
122  double result() const { return m_result; }
124  double error() const { return m_error; }
125 
126  protected:
127  StatusCode Exception( const std::string& message, const StatusCode& sc = StatusCode::FAILURE ) const;
128 
129  private:
130  // default constructor is disabled
132  // assignement operator is disabled
134 
135  private:
137  size_t m_index;
138  size_t m_DIM;
140  //
141  mutable Argument m_argument;
142  mutable double m_result;
143  mutable double m_error;
144  };
146  FUNCTION_OBJECT_IMP( NumericalDerivative )
147 
148  } // end of namespace GaudiMathImplementation
149 } // end of namespace GenFun
150 
151 #if defined( __clang__ ) || defined( __CLING__ )
152 #pragma clang diagnostic pop
153 #elif defined( __GNUC__ ) && __GNUC__ >= 5
154 #pragma GCC diagnostic pop
155 #endif
156 
157 // ============================================================================
158 // The END
159 // ============================================================================
160 #endif // GAUDIMATH_NUMERICALDERIVATIVE_H
161 // ============================================================================
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:27
PropertyMgr & operator=(const PropertyMgr &)=delete
STL class.
unsigned int dimensionality() const override
dimensionality of the problem
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
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:110
double result() const
the result of the last call