BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering

Description

Documentation for class Functor class. It is used to wrap in a very simple and convenient way multi-dimensional function objects. It can wrap all the following types:

  • any C++ callable object implemention double operator()( const double * )
  • a free C function of type double ()(const double * )
  • a member function with the correct signature like Foo::Eval(const double * ). In this case one pass the object pointer and a pointer to the member function (&Foo::Eval)

The function dimension is required when constructing the functor.

Definition at line 392 of file Functor.h.

Inheritance diagram for ROOT::Math::Functor:
[legend]
Collaboration diagram for ROOT::Math::Functor:
[legend]

Public Types

typedef T BackendType
 
typedef IBaseFunctionMultiDimTempl< T > BaseFunc
 
typedef FunctorImpl< IBaseFunctionMultiDimImpl
 
typedef IBaseFunctionMultiDim::BaseFunc ImplBase
 

Public Member Functions

 Functor ()
 
template<typename Func >
 Functor (const Func &f, unsigned int dim)
 
 Functor (const Functor &rhs)
 
template<class PtrObj , typename MemFn >
 Functor (const PtrObj &p, MemFn memFn, unsigned int dim)
 
virtual ~Functor ()
 
ImplBaseClone () const
 
unsigned int NDim () const
 
operator() (const T *x) const
 
Functoroperator= (const Functor &rhs)
 

Private Member Functions

double DoEval (const double *x) const
 

Private Attributes

std::unique_ptr< ImplfImpl
 

Member Typedef Documentation

◆ BackendType

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

Definition at line 66 of file IFunction.h.

◆ BaseFunc

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

Definition at line 67 of file IFunction.h.

◆ Impl

◆ ImplBase

Constructor & Destructor Documentation

◆ Functor() [1/4]

ROOT::Math::Functor::Functor ( )
inline

Default constructor

Definition at line 403 of file Functor.h.

403 {}

Referenced by Clone().

◆ Functor() [2/4]

template<class PtrObj , typename MemFn >
ROOT::Math::Functor::Functor ( const PtrObj &  p,
MemFn  memFn,
unsigned int  dim 
)
inline

construct from a pointer to member function (multi-dim type)

Definition at line 410 of file Functor.h.

411  : fImpl(new MemFunHandler<Functor, PtrObj, MemFn>(dim, p, memFn))
412  {}
std::unique_ptr< Impl > fImpl
Definition: Functor.h:467

◆ Functor() [3/4]

template<typename Func >
ROOT::Math::Functor::Functor ( const Func &  f,
unsigned int  dim 
)
inline

construct from a callable object of multi-dimension with the right signature (implementing operator()(double *x)

Definition at line 421 of file Functor.h.

421  :
422  fImpl(new FunctorHandler<Functor,Func>(dim,f) )
423  {}

◆ ~Functor()

virtual ROOT::Math::Functor::~Functor ( )
inlinevirtual

Destructor (no operations)

Definition at line 429 of file Functor.h.

429 {}

◆ Functor() [4/4]

ROOT::Math::Functor::Functor ( const Functor rhs)
inline

Copy constructor for functor based on ROOT::Math::IMultiGenFunction

Definition at line 434 of file Functor.h.

434  :
435  ImplBase()
436  {
437  if (rhs.fImpl)
438  fImpl = std::unique_ptr<Impl>((rhs.fImpl)->Copy());
439  }
IBaseFunctionMultiDim::BaseFunc ImplBase
Definition: Functor.h:398

References fImpl.

Member Function Documentation

◆ Clone()

ImplBase* ROOT::Math::Functor::Clone ( ) const
inlinevirtual

Clone a function. Each derived class must implement their version of the Clone method

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

Definition at line 454 of file Functor.h.

454 { return new Functor(*this); }

References Functor().

Here is the call graph for this function:

◆ DoEval()

double ROOT::Math::Functor::DoEval ( const double *  x) const
inlineprivate

Definition at line 462 of file Functor.h.

462  {
463  return (*fImpl)(x);
464  }

References fImpl.

◆ NDim()

unsigned int ROOT::Math::Functor::NDim ( ) const
inlinevirtual

Retrieve the dimension of the function

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

Definition at line 457 of file Functor.h.

457 { return fImpl->NDim(); }

References fImpl.

◆ operator()()

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:

◆ operator=()

Functor& ROOT::Math::Functor::operator= ( const Functor rhs)
inline

Assignment operator

Definition at line 446 of file Functor.h.

446  {
447  Functor copy(rhs);
448  fImpl.swap(copy.fImpl);
449  return *this;
450  }

References fImpl.

Member Data Documentation

◆ fImpl

std::unique_ptr<Impl> ROOT::Math::Functor::fImpl
private

Definition at line 467 of file Functor.h.

Referenced by Functor(), DoEval(), NDim(), and operator=().


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