The Gaudi Framework  v30r3 (a5ef0a68)
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 #include <memory>
16 
17 #if defined( __clang__ ) || defined( __CLING__ )
18 #pragma clang diagnostic push
19 #pragma clang diagnostic ignored "-Winconsistent-missing-override"
20 #elif defined( __GNUC__ ) && __GNUC__ >= 5
21 #pragma GCC diagnostic push
22 #pragma GCC diagnostic ignored "-Wsuggest-override"
23 #endif
24 
25 namespace Genfun
26 {
27  namespace GaudiMathImplementation
28  {
44  class GAUDI_API NumericalDerivative : public AbsFunction
45  {
46  public:
48  enum Type { Central, Forward, Backward };
49 
50  public:
52  FUNCTION_OBJECT_DEF( NumericalDerivative )
53 
54  public:
90  NumericalDerivative( const AbsFunction& function, const size_t index, const Type& type = Central );
91 
94 
96  unsigned int dimensionality() const override { return m_DIM; }
97 
99  double operator()( double argument ) const override;
101  double operator()( const Argument& argument ) const override;
102 
104  bool hasAnalyticDerivative() const override { return true; }
105 
107  Derivative partial( unsigned int index ) const override;
108 
109  public:
111  const AbsFunction& function() const { return *m_function; }
113  size_t index() const { return m_index; }
115  const Type& type() const { return m_type; }
116 
118  const Type& setType( const Type& value );
119 
121  double result() const { return m_result; }
123  double error() const { return m_error; }
124 
125  protected:
126  StatusCode Exception( const std::string& message, const StatusCode& sc = StatusCode::FAILURE ) const;
127 
128  private:
129  // default constructor is disabled
131  // assignement operator is disabled
133 
134  private:
136  size_t m_index;
137  size_t m_DIM;
139  //
140  mutable Argument m_argument;
141  mutable double m_result;
142  mutable double m_error;
143  };
145  FUNCTION_OBJECT_IMP( NumericalDerivative )
146 
147  } // end of namespace GaudiMathImplementation
148 } // end of namespace GenFun
149 
150 #if defined( __clang__ ) || defined( __CLING__ )
151 #pragma clang diagnostic pop
152 #elif defined( __GNUC__ ) && __GNUC__ >= 5
153 #pragma GCC diagnostic pop
154 #endif
155 
156 // ============================================================================
157 // The END
158 // ============================================================================
159 #endif // GAUDIMATH_NUMERICALDERIVATIVE_H
160 // ============================================================================
constexpr static const auto FAILURE
Definition: StatusCode.h:88
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:51
Numerical derivative (using GSL adaptive numerical differentiation)
virtual Out operator()(const vector_of_const_< In > &inputs) const =0
#define GAUDI_API
Definition: Kernel.h:104
double result() const
the result of the last call