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

Description

Functor1D class for one-dimensional functions. It is used to wrap in a very simple and convenient way:

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

Definition at line 487 of file Functor.h.

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

Public Types

typedef IBaseFunctionOneDim BaseFunc
 
typedef FunctorImpl< IBaseFunctionOneDimImpl
 
typedef IBaseFunctionOneDim::BaseFunc ImplBase
 

Public Member Functions

 Functor1D ()
 
template<typename Func >
 Functor1D (const Func &f)
 
 Functor1D (const Functor1D &rhs)
 
template<class PtrObj , typename MemFn >
 Functor1D (const PtrObj &p, MemFn memFn)
 
virtual ~Functor1D ()
 
ImplBaseClone () const
 
double operator() (const double *x) const
 
double operator() (double x) const
 
Functor1Doperator= (const Functor1D &rhs)
 

Private Member Functions

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

Private Attributes

std::unique_ptr< ImplfImpl
 

Member Typedef Documentation

◆ BaseFunc

Definition at line 139 of file IFunction.h.

◆ Impl

◆ ImplBase

Constructor & Destructor Documentation

◆ Functor1D() [1/4]

ROOT::Math::Functor1D::Functor1D ( )
inline

Default constructor

Definition at line 498 of file Functor.h.

498 {}

Referenced by Clone().

◆ Functor1D() [2/4]

template<typename Func >
ROOT::Math::Functor1D::Functor1D ( const Func &  f)
inline

construct from a callable object with the right signature implementing operator() (double x)

Definition at line 505 of file Functor.h.

505  :
506  fImpl(new FunctorHandler<Functor1D,Func>(f))
507  {}
std::unique_ptr< Impl > fImpl
Definition: Functor.h:555

◆ Functor1D() [3/4]

template<class PtrObj , typename MemFn >
ROOT::Math::Functor1D::Functor1D ( const PtrObj &  p,
MemFn  memFn 
)
inline

construct from a pointer to member function (1D type)

Definition at line 514 of file Functor.h.

515  : fImpl(new MemFunHandler<Functor1D, PtrObj, MemFn>(p, memFn))
516  {}

◆ ~Functor1D()

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

Destructor (no operations)

Definition at line 522 of file Functor.h.

522 {}

◆ Functor1D() [4/4]

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

Copy constructor for Functor based on ROOT::Math::IGenFunction

Definition at line 528 of file Functor.h.

528  :
529  // strange that this is required eventhough ImplBase is an abstract class
530  ImplBase()
531  {
532  if (rhs.fImpl)
533  fImpl = std::unique_ptr<Impl>( (rhs.fImpl)->Copy() );
534  }
IBaseFunctionOneDim::BaseFunc ImplBase
Definition: Functor.h:493

References fImpl.

Member Function Documentation

◆ Clone()

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

Clone a function. Each derived class will implement their version of the provate DoClone method

Implements ROOT::Math::IBaseFunctionOneDim.

Definition at line 547 of file Functor.h.

547 { return new Functor1D(*this); }

References Functor1D().

Here is the call graph for this function:

◆ DoEval()

double ROOT::Math::Functor1D::DoEval ( double  x) const
inlineprivatevirtual

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

Implements ROOT::Math::IBaseFunctionOneDim.

Definition at line 551 of file Functor.h.

551  {
552  return (*fImpl)(x);
553  }

References fImpl.

◆ 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:

◆ operator=()

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

Assignment operator

Definition at line 540 of file Functor.h.

540  {
541  Functor1D copy(rhs);
542  fImpl.swap(copy.fImpl);
543  return *this;
544  }

References fImpl.

Member Data Documentation

◆ fImpl

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

Definition at line 555 of file Functor.h.

Referenced by Functor1D(), DoEval(), and operator=().


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