BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
ROOT::Math::WrappedMemFunction< FuncObj, MemFuncPtr > Class Template Reference

Description

template<typename FuncObj, typename MemFuncPtr>
class ROOT::Math::WrappedMemFunction< FuncObj, MemFuncPtr >

Template class to wrap any member function of a class taking a double and returning a double in a 1D function interface For example, if you have a class like: struct X { double Eval(double x); }; you can wrapped in the following way: WrappedMemFunction<X, double ( X::* ) (double) > f;

Definition at line 106 of file WrappedFunction.h.

Inheritance diagram for ROOT::Math::WrappedMemFunction< FuncObj, MemFuncPtr >:
[legend]
Collaboration diagram for ROOT::Math::WrappedMemFunction< FuncObj, MemFuncPtr >:
[legend]

Public Types

typedef IBaseFunctionOneDim BaseFunc
 

Public Member Functions

 WrappedMemFunction (FuncObj &obj, MemFuncPtr memFn)
 
WrappedMemFunctionClone () const
 clone (required by the interface) More...
 
double operator() (const double *x) const
 
double operator() (double x) const
 

Private Member Functions

virtual double DoEval (double x) const
 implementation of the evaluation function. Must be implemented by derived classes More...
 

Private Attributes

MemFuncPtr fMemFunc
 
FuncObj * fObj
 

Member Typedef Documentation

◆ BaseFunc

Definition at line 139 of file IFunction.h.

Constructor & Destructor Documentation

◆ WrappedMemFunction()

template<typename FuncObj , typename MemFuncPtr >
ROOT::Math::WrappedMemFunction< FuncObj, MemFuncPtr >::WrappedMemFunction ( FuncObj &  obj,
MemFuncPtr  memFn 
)
inline

construct from the pointer to the object and the member function

Definition at line 114 of file WrappedFunction.h.

114  :
115  fObj(&obj),
116  fMemFunc( memFn )
117  { /* no op */ }

Referenced by ROOT::Math::WrappedMemFunction< FuncObj, MemFuncPtr >::Clone().

Member Function Documentation

◆ Clone()

template<typename FuncObj , typename MemFuncPtr >
WrappedMemFunction* ROOT::Math::WrappedMemFunction< FuncObj, MemFuncPtr >::Clone ( ) const
inlinevirtual

clone (required by the interface)

Implements ROOT::Math::IBaseFunctionOneDim.

Definition at line 122 of file WrappedFunction.h.

122  {
123  return new WrappedMemFunction(*fObj,fMemFunc);
124  }
WrappedMemFunction(FuncObj &obj, MemFuncPtr memFn)

References ROOT::Math::WrappedMemFunction< FuncObj, MemFuncPtr >::WrappedMemFunction(), ROOT::Math::WrappedMemFunction< FuncObj, MemFuncPtr >::fMemFunc, and ROOT::Math::WrappedMemFunction< FuncObj, MemFuncPtr >::fObj.

Here is the call graph for this function:

◆ DoEval()

template<typename FuncObj , typename MemFuncPtr >
virtual double ROOT::Math::WrappedMemFunction< FuncObj, MemFuncPtr >::DoEval ( double  x) const
inlineprivatevirtual

implementation of the evaluation function. Must be implemented by derived classes

Implements ROOT::Math::IBaseFunctionOneDim.

Definition at line 129 of file WrappedFunction.h.

129  {
130  return ((*fObj).*fMemFunc)( x );
131  }

References ROOT::Math::WrappedMemFunction< FuncObj, MemFuncPtr >::fMemFunc.

◆ operator()() [1/2]

double ROOT::Math::IBaseFunctionOneDim::operator() ( const double *  x) const
inlineinherited

Evaluate the function at a point x[]. Compatible method with multi-dimensional functions

Definition at line 167 of file IFunction.h.

168  {
169  return DoEval(*x);
170  }
virtual double DoEval(double x) const =0
implementation of the evaluation function. Must be implemented by derived classes

References ROOT::Math::IBaseFunctionOneDim::DoEval().

Here is the call graph for this function:

◆ operator()() [2/2]

double ROOT::Math::IBaseFunctionOneDim::operator() ( double  x) const
inlineinherited

Evaluate the function at a point x Use the a pure virtual private method DoEval which must be implemented by sub-classes

Definition at line 158 of file IFunction.h.

159  {
160  return DoEval(x);
161  }

References ROOT::Math::IBaseFunctionOneDim::DoEval().

Referenced by ROOT::Math::IGradientFunctionOneDim::FdF().

Here is the call graph for this function:

Member Data Documentation

◆ fMemFunc

template<typename FuncObj , typename MemFuncPtr >
MemFuncPtr ROOT::Math::WrappedMemFunction< FuncObj, MemFuncPtr >::fMemFunc
private

◆ fObj

template<typename FuncObj , typename MemFuncPtr >
FuncObj* ROOT::Math::WrappedMemFunction< FuncObj, MemFuncPtr >::fObj
private

The documentation for this class was generated from the following file: