Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
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 #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  namespace GaudiMathImplementation {
42  class GAUDI_API NumericalDerivative : public AbsFunction {
43  public:
45  enum Type { Central, Forward, Backward };
46 
47  public:
49  FUNCTION_OBJECT_DEF( NumericalDerivative )
50 
51  public:
87  NumericalDerivative( const AbsFunction& function, const size_t index, const Type& type = Central );
88 
91 
93  unsigned int dimensionality() const override { return m_DIM; }
94 
96  double operator()( double argument ) const override;
98  double operator()( const Argument& argument ) const override;
99 
101  bool hasAnalyticDerivative() const override { return true; }
102 
104  Derivative partial( unsigned int index ) const override;
105 
106  public:
108  const AbsFunction& function() const { return *m_function; }
110  size_t index() const { return m_index; }
112  const Type& type() const { return m_type; }
113 
115  const Type& setType( const Type& value );
116 
118  double result() const { return m_result; }
120  double error() const { return m_error; }
121 
122  protected:
123  StatusCode Exception( const std::string& message, const StatusCode& sc = StatusCode::FAILURE ) const;
124 
125  private:
126  // default constructor is disabled
128  // assignement operator is disabled
130 
131  private:
133  size_t m_index;
134  size_t m_DIM;
136  //
137  mutable Argument m_argument;
138  mutable double m_result;
139  mutable double m_error;
140  };
142  FUNCTION_OBJECT_IMP( NumericalDerivative )
143 
144  } // end of namespace GaudiMathImplementation
145 } // namespace Genfun
146 
147 #if defined( __clang__ ) || defined( __CLING__ )
148 # pragma clang diagnostic pop
149 #elif defined( __GNUC__ ) && __GNUC__ >= 5
150 # pragma GCC diagnostic pop
151 #endif
152 
153 // ============================================================================
154 // The END
155 // ============================================================================
156 #endif // GAUDIMATH_NUMERICALDERIVATIVE_H
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:26
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:50
Numerical derivative (using GSL adaptive numerical differentiation)
virtual Out operator()(const vector_of_const_< In > &inputs) const =0
constexpr static const auto FAILURE
Definition: StatusCode.h:86
CLHEP.
Definition: IEqSolver.h:13
#define GAUDI_API
Definition: Kernel.h:71
double result() const
the result of the last call