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::MinimTransformFunction Class Reference

Description

MinimTransformFunction class to perform a transformations on the variables to deal with fixed or limited variables (support both double and single bounds) The class manages the passed function pointer

Definition at line 39 of file MinimTransformFunction.h.

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

Public Types

typedef T BackendType
 
typedef ROOT::Math::IMultiGradFunction::BaseFunc BaseFunc
 
typedef IGradientMultiDimTempl< T > BaseGrad
 
typedef ROOT::Math::IMultiGradFunction BaseGradFunc
 

Public Member Functions

 MinimTransformFunction (const IMultiGradFunction *f, const std::vector< ROOT::Math::EMinimVariableType > &types, const std::vector< double > &values, const std::map< unsigned int, std::pair< double, double > > &bounds)
 
 ~MinimTransformFunction ()
 
IMultiGenFunctionClone () const
 clone: not supported (since unique_ptr used in the fVariables) More...
 
Derivative (const T *x, unsigned int icoord=0) const
 
virtual void FdF (const T *x, T &f, T *df) const
 
virtual void Gradient (const T *x, T *grad) const
 
void GradientTransformation (const double *x, const double *gExt, double *gInt) const
 transform gradient vector (external -> internal) at internal point x More...
 
void InvStepTransformation (const double *x, const double *sext, double *sint) const
 inverse transformation for steps (external -> internal) at external point x More...
 
void InvTransformation (const double *xext, double *xint) const
 inverse transformation (external -> internal) More...
 
void MatrixTransformation (const double *x, const double *covInt, double *covExt) const
 transform covariance matrix (internal -> external) at internal point x use row storages for matrices m(i,j) = rep[ i * dim + j] More...
 
unsigned int NDim () const
 
virtual unsigned int NDim () const=0
 
unsigned int NTot () const
 
operator() (const T *x) const
 
const IMultiGradFunctionOriginalFunction () const
 
const double * Transformation (const double *x) const
 transform from internal to external result is cached also inside the class More...
 
void Transformation (const double *xint, double *xext) const
 transform from internal to external More...
 

Private Member Functions

 MinimTransformFunction (const MinimTransformFunction &)
 
virtual double DoDerivative (const double *x, unsigned int icoord) const
 calculate derivatives More...
 
virtual double DoEval (const double *x) const
 function evaluation More...
 
MinimTransformFunctionoperator= (const MinimTransformFunction &)
 

Private Attributes

const IMultiGradFunctionfFunc
 
std::vector< unsigned int > fIndex
 
std::vector< MinimTransformVariablefVariables
 
std::vector< double > fX
 

Member Typedef Documentation

◆ BackendType

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

Definition at line 66 of file IFunction.h.

◆ BaseFunc

◆ BaseGrad

template<class T >
typedef IGradientMultiDimTempl<T> ROOT::Math::IGradientFunctionMultiDimTempl< T >::BaseGrad
inherited

Definition at line 331 of file IFunction.h.

◆ BaseGradFunc

Constructor & Destructor Documentation

◆ MinimTransformFunction() [1/2]

ROOT::Math::MinimTransformFunction::MinimTransformFunction ( const IMultiGradFunction f,
const std::vector< ROOT::Math::EMinimVariableType > &  types,
const std::vector< double > &  values,
const std::map< unsigned int, std::pair< double, double > > &  bounds 
)

Constructor from a IMultiGradFunction interface (which is managed by the class) vector specifying the variable types (free, bounded or fixed, defined in enum EMinimVariableTypes ) variable values (used for the fixed ones) and a map with the bounds (for the bounded variables)

◆ ~MinimTransformFunction()

ROOT::Math::MinimTransformFunction::~MinimTransformFunction ( )
inline

Destructor (delete function pointer)

Definition at line 60 of file MinimTransformFunction.h.

60  {
61  if (fFunc) delete fFunc;
62  }

References fFunc.

◆ MinimTransformFunction() [2/2]

ROOT::Math::MinimTransformFunction::MinimTransformFunction ( const MinimTransformFunction )
inlineprivate

Definition at line 128 of file MinimTransformFunction.h.

128  :
130  {}
ROOT::Math::IMultiGradFunction::BaseFunc BaseFunc
ROOT::Math::IMultiGradFunction BaseGradFunc

Member Function Documentation

◆ Clone()

IMultiGenFunction* ROOT::Math::MinimTransformFunction::Clone ( ) const
inlinevirtual

clone: not supported (since unique_ptr used in the fVariables)

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

Definition at line 72 of file MinimTransformFunction.h.

72  {
73  return 0;
74  }

◆ Derivative()

template<class T >
T ROOT::Math::IGradientMultiDimTempl< T >::Derivative ( const T *  x,
unsigned int  icoord = 0 
) const
inlineinherited

Return the partial derivative with respect to the passed coordinate

Definition at line 217 of file IFunction.h.

217 { return DoDerivative(x, icoord); }
virtual T DoDerivative(const T *x, unsigned int icoord) const =0

References ROOT::Math::IGradientMultiDimTempl< T >::DoDerivative().

Referenced by DoDerivative(), and ROOT::Math::IGradientFunctionMultiDimTempl< T >::Gradient().

Here is the call graph for this function:

◆ DoDerivative()

virtual double ROOT::Math::MinimTransformFunction::DoDerivative ( const double *  x,
unsigned int  icoord 
) const
inlineprivatevirtual

calculate derivatives

Definition at line 119 of file MinimTransformFunction.h.

119  {
120  const MinimTransformVariable & var = fVariables[ fIndex[icoord] ];
121  double dExtdInt = (var.IsLimited() ) ? var.DerivativeIntToExt( x[icoord] ) : 1.0;
122  double deriv = fFunc->Derivative( Transformation(x) , fIndex[icoord] );
123  //std::cout << "Derivative icoord (ext)" << fIndex[icoord] << " dtrafo " << dExtdInt << " " << deriv << std::endl;
124  return deriv * dExtdInt;
125  }
T Derivative(const T *x, unsigned int icoord=0) const
Definition: IFunction.h:217
const double * Transformation(const double *x) const
transform from internal to external result is cached also inside the class
std::vector< MinimTransformVariable > fVariables

References ROOT::Math::IGradientMultiDimTempl< T >::Derivative(), ROOT::Math::MinimTransformVariable::DerivativeIntToExt(), fFunc, fIndex, fVariables, ROOT::Math::MinimTransformVariable::IsLimited(), and Transformation().

Here is the call graph for this function:

◆ DoEval()

virtual double ROOT::Math::MinimTransformFunction::DoEval ( const double *  x) const
inlineprivatevirtual

function evaluation

Definition at line 108 of file MinimTransformFunction.h.

108  {
109 #ifndef DO_THREADSAFE
110  return (*fFunc)(Transformation(x));
111 #else
112  std::vector<double> xext(fVariables.size() );
113  Transformation(x, &xext[0]);
114  return (*fFunc)(&xext[0]);
115 #endif
116  }

References fFunc, fVariables, and Transformation().

Here is the call graph for this function:

◆ FdF()

template<class T >
virtual void ROOT::Math::IGradientFunctionMultiDimTempl< T >::FdF ( const T *  x,
T &  f,
T *  df 
) const
inlinevirtualinherited

Optimized method to evaluate at the same time the function value and derivative at a point x. Often both value and derivatives are needed and it is often more efficient to compute them at the same time. Derived class should implement this method if performances play an important role and if it is faster to evaluate value and derivative at the same time

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

Definition at line 357 of file IFunction.h.

358  {
359  f = BaseFunc::operator()(x);
360  Gradient(x, df);
361  }
virtual void Gradient(const T *x, T *grad) const
Definition: IFunction.h:342

References ROOT::Math::IGradientFunctionMultiDimTempl< T >::Gradient(), and ROOT::Math::IBaseFunctionMultiDimTempl< T >::operator()().

Here is the call graph for this function:

◆ Gradient()

template<class T >
virtual void ROOT::Math::IGradientFunctionMultiDimTempl< T >::Gradient ( const T *  x,
T *  grad 
) const
inlinevirtualinherited

Evaluate all the vector of function derivatives (gradient) at a point x. Derived classes must re-implement it if more efficient than evaluting one at a time

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

Definition at line 342 of file IFunction.h.

343  {
344  unsigned int ndim = NDim();
345  for (unsigned int icoord = 0; icoord < ndim; ++icoord)
346  grad[icoord] = BaseGrad::Derivative(x, icoord);
347  }
virtual unsigned int NDim() const=0

References ROOT::Math::IGradientMultiDimTempl< T >::Derivative(), and ROOT::Math::IGradientFunctionMultiDimTempl< T >::NDim().

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

Here is the call graph for this function:

◆ GradientTransformation()

void ROOT::Math::MinimTransformFunction::GradientTransformation ( const double *  x,
const double *  gExt,
double *  gInt 
) const

transform gradient vector (external -> internal) at internal point x

◆ InvStepTransformation()

void ROOT::Math::MinimTransformFunction::InvStepTransformation ( const double *  x,
const double *  sext,
double *  sint 
) const

inverse transformation for steps (external -> internal) at external point x

◆ InvTransformation()

void ROOT::Math::MinimTransformFunction::InvTransformation ( const double *  xext,
double *  xint 
) const

inverse transformation (external -> internal)

◆ MatrixTransformation()

void ROOT::Math::MinimTransformFunction::MatrixTransformation ( const double *  x,
const double *  covInt,
double *  covExt 
) const

transform covariance matrix (internal -> external) at internal point x use row storages for matrices m(i,j) = rep[ i * dim + j]

◆ NDim() [1/2]

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

Retrieve the dimension of the function

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

Definition at line 67 of file MinimTransformFunction.h.

67 { return fIndex.size(); }

References fIndex.

◆ NDim() [2/2]

template<class T >
virtual unsigned int ROOT::Math::IBaseFunctionMultiDimTempl< T >::NDim
inherited

◆ NTot()

unsigned int ROOT::Math::MinimTransformFunction::NTot ( ) const
inline

Definition at line 69 of file MinimTransformFunction.h.

69 { return fFunc->NDim(); }

References fFunc, and ROOT::Math::IGradientFunctionMultiDimTempl< T >::NDim().

Here is the call graph for this function:

◆ 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=()

MinimTransformFunction& ROOT::Math::MinimTransformFunction::operator= ( const MinimTransformFunction )
inlineprivate

Definition at line 133 of file MinimTransformFunction.h.

133  {
134  return *this;
135  }

◆ OriginalFunction()

const IMultiGradFunction* ROOT::Math::MinimTransformFunction::OriginalFunction ( ) const
inline

Definition at line 102 of file MinimTransformFunction.h.

102 { return fFunc; }

References fFunc.

◆ Transformation() [1/2]

const double* ROOT::Math::MinimTransformFunction::Transformation ( const double *  x) const
inline

transform from internal to external result is cached also inside the class

Definition at line 79 of file MinimTransformFunction.h.

79  {
80  Transformation(x, &fX[0]);
81  return &fX.front();
82  }

References fX.

Referenced by DoDerivative(), and DoEval().

◆ Transformation() [2/2]

void ROOT::Math::MinimTransformFunction::Transformation ( const double *  xint,
double *  xext 
) const

transform from internal to external

Member Data Documentation

◆ fFunc

const IMultiGradFunction* ROOT::Math::MinimTransformFunction::fFunc
private

◆ fIndex

std::vector<unsigned int> ROOT::Math::MinimTransformFunction::fIndex
private

Definition at line 143 of file MinimTransformFunction.h.

Referenced by DoDerivative(), and NDim().

◆ fVariables

std::vector<MinimTransformVariable> ROOT::Math::MinimTransformFunction::fVariables
private

Definition at line 142 of file MinimTransformFunction.h.

Referenced by DoDerivative(), and DoEval().

◆ fX

std::vector<double> ROOT::Math::MinimTransformFunction::fX
mutableprivate

Definition at line 141 of file MinimTransformFunction.h.

Referenced by Transformation().


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