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::OneDimParamFunctionAdapter< ParamFuncType > Class Template Reference

Description

template<class ParamFuncType = ROOT::Math::IParamMultiFunction &>
class ROOT::Math::OneDimParamFunctionAdapter< ParamFuncType >

OneDimParamFunctionAdapter class to wrap a multi-dim parameteric function in one dimensional one. Given a f(x[],p1,...pn) transforms in a f( p_i) given the param index i and the vectors x[] and p[] of the coordinates and parameters It has to be used carefully, since for efficiency reason it does not copy the parameter object but re-uses the given pointer for the p[] vector. The ParamFuncType reference by default is not const because the operator()(x,p) is not a const method

Definition at line 213 of file OneDimFunctionAdapter.h.

Inheritance diagram for ROOT::Math::OneDimParamFunctionAdapter< ParamFuncType >:
[legend]
Collaboration diagram for ROOT::Math::OneDimParamFunctionAdapter< ParamFuncType >:
[legend]

Public Types

typedef IBaseFunctionOneDim BaseFunc
 

Public Member Functions

 OneDimParamFunctionAdapter (ParamFuncType f, const double *x, const double *p, unsigned int ipar=0)
 
 ~OneDimParamFunctionAdapter ()
 
virtual OneDimParamFunctionAdapterClone () const
 
double operator() (const double *x) const
 
double operator() (double x) const
 

Private Member Functions

double DoEval (double x) const
 

Private Attributes

ParamFuncType fFunc
 
unsigned int fIpar
 
const double * fParams
 
const double * fX
 

Member Typedef Documentation

◆ BaseFunc

Definition at line 139 of file IFunction.h.

Constructor & Destructor Documentation

◆ OneDimParamFunctionAdapter()

template<class ParamFuncType = ROOT::Math::IParamMultiFunction &>
ROOT::Math::OneDimParamFunctionAdapter< ParamFuncType >::OneDimParamFunctionAdapter ( ParamFuncType  f,
const double *  x,
const double *  p,
unsigned int  ipar = 0 
)
inline

Constructor from the function object , x value and coordinate we want to adapt

Definition at line 221 of file OneDimFunctionAdapter.h.

221  :
222  fFunc(f),
223  fX(x ),
224  fParams(p),
225  fIpar(ipar)
226  {
227  assert(fX != 0);
228  assert(fParams != 0);
229  }

References ROOT::Math::OneDimParamFunctionAdapter< ParamFuncType >::fParams, and ROOT::Math::OneDimParamFunctionAdapter< ParamFuncType >::fX.

Referenced by ROOT::Math::OneDimParamFunctionAdapter< ParamFuncType >::Clone().

◆ ~OneDimParamFunctionAdapter()

template<class ParamFuncType = ROOT::Math::IParamMultiFunction &>
ROOT::Math::OneDimParamFunctionAdapter< ParamFuncType >::~OneDimParamFunctionAdapter ( )
inline

Destructor (no operations)

Definition at line 234 of file OneDimFunctionAdapter.h.

234 {}

Member Function Documentation

◆ Clone()

template<class ParamFuncType = ROOT::Math::IParamMultiFunction &>
virtual OneDimParamFunctionAdapter* ROOT::Math::OneDimParamFunctionAdapter< ParamFuncType >::Clone ( ) const
inlinevirtual

clone

Implements ROOT::Math::IBaseFunctionOneDim.

Definition at line 239 of file OneDimFunctionAdapter.h.

239  {
241  }
OneDimParamFunctionAdapter(ParamFuncType f, const double *x, const double *p, unsigned int ipar=0)

References ROOT::Math::OneDimParamFunctionAdapter< ParamFuncType >::OneDimParamFunctionAdapter(), ROOT::Math::OneDimParamFunctionAdapter< ParamFuncType >::fFunc, ROOT::Math::OneDimParamFunctionAdapter< ParamFuncType >::fIpar, ROOT::Math::OneDimParamFunctionAdapter< ParamFuncType >::fParams, and ROOT::Math::OneDimParamFunctionAdapter< ParamFuncType >::fX.

Here is the call graph for this function:

◆ DoEval()

template<class ParamFuncType = ROOT::Math::IParamMultiFunction &>
double ROOT::Math::OneDimParamFunctionAdapter< ParamFuncType >::DoEval ( double  x) const
inlineprivatevirtual

evaluate function at the values x[] given in the constructor and as function of the coordinate fCoord.

Implements ROOT::Math::IBaseFunctionOneDim.

Definition at line 251 of file OneDimFunctionAdapter.h.

251  {
252  // HACK: use const_cast to modify the function values x[] and restore afterwards the original ones
253  double * p = const_cast<double *>(fParams);
254  double pprev = fParams[fIpar]; // keep original value to restore in fX
255  p[fIpar] = x;
256  double y = fFunc( fX, p );
257  p[fIpar] = pprev;
258  return y;
259  }

References ROOT::Math::OneDimParamFunctionAdapter< ParamFuncType >::fFunc, ROOT::Math::OneDimParamFunctionAdapter< ParamFuncType >::fIpar, ROOT::Math::OneDimParamFunctionAdapter< ParamFuncType >::fParams, and ROOT::Math::OneDimParamFunctionAdapter< ParamFuncType >::fX.

◆ 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

◆ fFunc

template<class ParamFuncType = ROOT::Math::IParamMultiFunction &>
ParamFuncType ROOT::Math::OneDimParamFunctionAdapter< ParamFuncType >::fFunc
private

◆ fIpar

template<class ParamFuncType = ROOT::Math::IParamMultiFunction &>
unsigned int ROOT::Math::OneDimParamFunctionAdapter< ParamFuncType >::fIpar
private

◆ fParams

◆ fX


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