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::WrappedParamFunction< FuncPtr > Class Template Reference

Description

template<typename FuncPtr = FreeParamMultiFunctionPtr>
class ROOT::Math::WrappedParamFunction< FuncPtr >

WrappedParamFunction class to wrap any multi-dimensional function pbject implementing the operator()(const double * x, const double * p) in an interface-like IParamFunction with a vector storing and caching internally the parameter values

Definition at line 41 of file WrappedParamFunction.h.

Inheritance diagram for ROOT::Math::WrappedParamFunction< FuncPtr >:
[legend]
Collaboration diagram for ROOT::Math::WrappedParamFunction< FuncPtr >:
[legend]

Public Types

typedef T BackendType
 
typedef IBaseFunctionMultiDimTempl< double > BaseFunc
 

Public Member Functions

template<class Iterator >
 WrappedParamFunction (FuncPtr func, unsigned int dim, Iterator begin, Iterator end)
 
 WrappedParamFunction (FuncPtr func, unsigned int dim=1, unsigned int npar=0, double *par=0)
 
IMultiGenFunctionClone () const
 clone the function More...
 
unsigned int NDim () const
 
unsigned int NPar () const
 
double operator() (const double *x) const
 
double operator() (const double *x, const double *p) const
 
operator() (const T *x) const
 
virtual std::string ParameterName (unsigned int i) const
 
const double * Parameters () const
 
void SetParameters (const double *p)
 

Private Member Functions

virtual double DoEval (const double *x) const
 
double DoEvalPar (const double *x, const double *p) const
 evaluate the function given values and parameters (requested interface) More...
 

Private Attributes

unsigned int fDim
 
FuncPtr fFunc
 
std::vector< double > fParams
 

Member Typedef Documentation

◆ BackendType

template<class T >
typedef T ROOT::Math::IBaseFunctionMultiDimTempl< T >::BackendType
inherited

Definition at line 66 of file IFunction.h.

◆ BaseFunc

Definition at line 108 of file IParamFunction.h.

Constructor & Destructor Documentation

◆ WrappedParamFunction() [1/2]

template<typename FuncPtr = FreeParamMultiFunctionPtr>
ROOT::Math::WrappedParamFunction< FuncPtr >::WrappedParamFunction ( FuncPtr  func,
unsigned int  dim = 1,
unsigned int  npar = 0,
double *  par = 0 
)
inline

Constructor a wrapped function from a pointer to a callable object, the function dimension and number of parameters which are set to zero by default

Definition at line 49 of file WrappedParamFunction.h.

49  :
50  fFunc(func),
51  fDim(dim),
52  fParams(std::vector<double>(npar) )
53  {
54  if (par != 0) std::copy(par,par+npar,fParams.begin() );
55  }

References ROOT::Math::WrappedParamFunction< FuncPtr >::fParams.

Referenced by ROOT::Math::WrappedParamFunction< FuncPtr >::Clone().

◆ WrappedParamFunction() [2/2]

template<typename FuncPtr = FreeParamMultiFunctionPtr>
template<class Iterator >
ROOT::Math::WrappedParamFunction< FuncPtr >::WrappedParamFunction ( FuncPtr  func,
unsigned int  dim,
Iterator  begin,
Iterator  end 
)
inline

Constructor a wrapped function from a pointer to a callable object, the function dimension and an iterator specifying begin and end of parameters

Definition at line 75 of file WrappedParamFunction.h.

75  :
76  fFunc(func),
77  fDim(dim),
78  fParams(std::vector<double>(begin,end) )
79  {}

Member Function Documentation

◆ Clone()

template<typename FuncPtr = FreeParamMultiFunctionPtr>
IMultiGenFunction* ROOT::Math::WrappedParamFunction< FuncPtr >::Clone ( ) const
inlinevirtual

clone the function

Implements ROOT::Math::IBaseFunctionMultiDimTempl< T >.

Definition at line 93 of file WrappedParamFunction.h.

93  {
94  return new WrappedParamFunction(fFunc, fDim, fParams.begin(), fParams.end());
95  }
WrappedParamFunction(FuncPtr func, unsigned int dim=1, unsigned int npar=0, double *par=0)

References ROOT::Math::WrappedParamFunction< FuncPtr >::WrappedParamFunction(), ROOT::Math::WrappedParamFunction< FuncPtr >::fDim, ROOT::Math::WrappedParamFunction< FuncPtr >::fFunc, and ROOT::Math::WrappedParamFunction< FuncPtr >::fParams.

Here is the call graph for this function:

◆ DoEval()

virtual double ROOT::Math::IParametricFunctionMultiDimTempl< double >::DoEval ( const double *  x) const
inlineprivatevirtualinherited

Implement the ROOT::Math::IBaseFunctionMultiDim interface DoEval(x) using the cached parameter values

Reimplemented in ROOT::Math::WrappedParamFunctionGen< FuncPtr >.

Definition at line 140 of file IParamFunction.h.

141  {
142  return DoEvalPar(x, Parameters());
143  }
virtual const double * Parameters() const =0
virtual double DoEvalPar(const double *x, const double *p) const=0

◆ DoEvalPar()

template<typename FuncPtr = FreeParamMultiFunctionPtr>
double ROOT::Math::WrappedParamFunction< FuncPtr >::DoEvalPar ( const double *  x,
const double *  p 
) const
inlineprivatevirtual

evaluate the function given values and parameters (requested interface)

Implements ROOT::Math::IParametricFunctionMultiDimTempl< double >.

Definition at line 113 of file WrappedParamFunction.h.

113  {
114  return (*fFunc)( x, p );
115  }

References ROOT::Math::WrappedParamFunction< FuncPtr >::fFunc.

◆ NDim()

template<typename FuncPtr = FreeParamMultiFunctionPtr>
unsigned int ROOT::Math::WrappedParamFunction< FuncPtr >::NDim ( ) const
inlinevirtual

Retrieve the dimension of the function

Implements ROOT::Math::IBaseFunctionMultiDimTempl< T >.

Definition at line 107 of file WrappedParamFunction.h.

107 { return fDim; }

References ROOT::Math::WrappedParamFunction< FuncPtr >::fDim.

◆ NPar()

template<typename FuncPtr = FreeParamMultiFunctionPtr>
unsigned int ROOT::Math::WrappedParamFunction< FuncPtr >::NPar ( ) const
inlinevirtual

Return the number of Parameters

Implements ROOT::Math::IBaseParam.

Definition at line 105 of file WrappedParamFunction.h.

105 { return fParams.size(); }

References ROOT::Math::WrappedParamFunction< FuncPtr >::fParams.

Referenced by ROOT::Math::WrappedParamFunction< FuncPtr >::SetParameters().

◆ operator()() [1/3]

double ROOT::Math::IParametricFunctionMultiDimTempl< double >::operator() ( const double *  x) const
inlineinherited

Definition at line 125 of file IParamFunction.h.

126  {
127  return DoEval(x);
128  }
virtual double DoEval(const double *x) const

◆ operator()() [2/3]

double ROOT::Math::IParametricFunctionMultiDimTempl< double >::operator() ( const double *  x,
const double *  p 
) const
inlineinherited

Evaluate function at a point x and for given parameters p. This method does not change the internal status of the function (internal parameter values). If for some reason one prefers caching the parameter values, SetParameters(p) and then operator()(x) should be called. Use the pure virtual function DoEvalPar to implement it

Definition at line 120 of file IParamFunction.h.

121  {
122  return DoEvalPar(x, p);
123  }

◆ operator()() [3/3]

template<class T >
T ROOT::Math::IBaseFunctionMultiDimTempl< T >::operator() ( const T *  x) const
inlineinherited

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

Definition at line 92 of file IFunction.h.

93  {
94  return DoEval(x);
95  }
virtual T DoEval(const T *x) const =0

References ROOT::Math::IBaseFunctionMultiDimTempl< T >::DoEval().

Referenced by ROOT::Math::IGradientFunctionMultiDimTempl< T >::FdF().

Here is the call graph for this function:

◆ ParameterName()

virtual std::string ROOT::Math::IBaseParam::ParameterName ( unsigned int  i) const
inlinevirtualinherited

Return the name of the i-th parameter (starting from zero) Overwrite if want to avoid the default name ("Par_0, Par_1, ...")

Definition at line 83 of file IParamFunction.h.

84  {
85  assert(i < NPar());
86  return "Par_" + Util::ToString(i);
87  }
virtual unsigned int NPar() const =0
std::string ToString(const T &val)
Definition: Util.h:42

References ROOT::Math::IBaseParam::NPar(), and ROOT::Math::Util::ToString().

Referenced by ROOT::Fit::FitConfig::CreateParamsSettings().

Here is the call graph for this function:

◆ Parameters()

template<typename FuncPtr = FreeParamMultiFunctionPtr>
const double* ROOT::Math::WrappedParamFunction< FuncPtr >::Parameters ( ) const
inlinevirtual

Access the parameter values

Implements ROOT::Math::IBaseParam.

Definition at line 97 of file WrappedParamFunction.h.

97  {
98  return fParams.empty() ? nullptr : &fParams.front();
99  }

References ROOT::Math::WrappedParamFunction< FuncPtr >::fParams.

◆ SetParameters()

template<typename FuncPtr = FreeParamMultiFunctionPtr>
void ROOT::Math::WrappedParamFunction< FuncPtr >::SetParameters ( const double *  p)
inlinevirtual

Set the parameter values

Parameters
pvector of doubles containing the parameter values.

to be defined: can user change number of params ? At the moment no.

Implements ROOT::Math::IBaseParam.

Definition at line 101 of file WrappedParamFunction.h.

101  {
102  std::copy(p, p+NPar(), fParams.begin() );
103  }

References ROOT::Math::WrappedParamFunction< FuncPtr >::fParams, and ROOT::Math::WrappedParamFunction< FuncPtr >::NPar().

Here is the call graph for this function:

Member Data Documentation

◆ fDim

template<typename FuncPtr = FreeParamMultiFunctionPtr>
unsigned int ROOT::Math::WrappedParamFunction< FuncPtr >::fDim
private

◆ fFunc

template<typename FuncPtr = FreeParamMultiFunctionPtr>
FuncPtr ROOT::Math::WrappedParamFunction< FuncPtr >::fFunc
private

◆ fParams


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