Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
ROOT::Math::LSResidualFunc< Func > Class Template Reference

template<class Func>
class ROOT::Math::LSResidualFunc< Func >

LSResidualFunc class description.

Internal class used for accessing the residuals of the Least Square function and their derivatives which are estimated numerically using GSL numerical derivation. The class contains a pointer to the fit method function and an index specifying the i-th residual and wraps it in a multi-dim gradient function interface ROOT::Math::IGradientFunctionMultiDim. The class is used by ROOT::Math::GSLNLSMinimizer (GSL non linear least square fitter)

Definition at line 135 of file GSLNLSMinimizer.cxx.

Public Types

typedef double BackendType
typedef IBaseFunctionMultiDimTempl< doubleBaseFunc

Public Member Functions

 LSResidualFunc (const Func &func, unsigned int i)
 LSResidualFunc (const LSResidualFunc< Func > &rhs)
IMultiGenFunctionClone () const override
 Clone a function.
double Derivative (const double *x, unsigned int icoord, double *previous_grad, double *previous_g2, double *previous_gstep) const
 In some cases, the derivative algorithm will use information from the previous step, these can be passed in with this overload.
double Derivative (const double *x, unsigned int icoord=0) const
 Return the partial derivative with respect to the passed coordinate.
void FdF (const double *x, double &f, double *g) const override
 Optimized method to evaluate at the same time the function value and derivative at a point x.
void Gradient (const double *x, double *g) const override
 Evaluate all the vector of function derivatives (gradient) at a point x.
bool HasGradient () const override
bool IsLSType () const
unsigned int NDim () const override
 Retrieve the dimension of the function.
double operator() (const double *x) const
 Evaluate the function at a point x[].
LSResidualFunc< Func > & operator= (const LSResidualFunc< Func > &rhs)

Private Member Functions

double DoDerivative (const double *, unsigned int) const override
 Function to evaluate the derivative with respect each coordinate. To be implemented by the derived class.
virtual double DoDerivativeWithPrevResult (const double *x, unsigned int icoord, double *, double *, double *) const
 In some cases, the derivative algorithm will use information from the previous step, these can be passed in with this overload.
double DoEval (const double *x) const override
 Implementation of the evaluation function. Must be implemented by derived classes.

Private Attributes

const Func * fChi2
unsigned int fIndex
Inheritance diagram for ROOT::Math::LSResidualFunc< Func >:
ROOT::Math::IGradientFunctionMultiDimTempl< double > ROOT::Math::IBaseFunctionMultiDimTempl< double >

Member Typedef Documentation

◆ BackendType

typedef double ROOT::Math::IBaseFunctionMultiDimTempl< double >::BackendType
inherited

Definition at line 67 of file IFunction.h.

◆ BaseFunc

Definition at line 68 of file IFunction.h.

Constructor & Destructor Documentation

◆ LSResidualFunc() [1/2]

template<class Func>
ROOT::Math::LSResidualFunc< Func >::LSResidualFunc ( const Func & func,
unsigned int i )
inline

Definition at line 137 of file GSLNLSMinimizer.cxx.

◆ LSResidualFunc() [2/2]

template<class Func>
ROOT::Math::LSResidualFunc< Func >::LSResidualFunc ( const LSResidualFunc< Func > & rhs)
inline

Definition at line 140 of file GSLNLSMinimizer.cxx.

Member Function Documentation

◆ Clone()

template<class Func>
IMultiGenFunction * ROOT::Math::LSResidualFunc< Func >::Clone ( ) const
inlineoverridevirtual

Clone a function.

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

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

Definition at line 150 of file GSLNLSMinimizer.cxx.

◆ Derivative() [1/2]

double ROOT::Math::IBaseFunctionMultiDimTempl< double >::Derivative ( const double * x,
unsigned int icoord,
double * previous_grad,
double * previous_g2,
double * previous_gstep ) const
inlineinherited

In some cases, the derivative algorithm will use information from the previous step, these can be passed in with this overload.

The previous_* arrays can also be used to return second derivative and step size so that these can be passed forward again as well at the call site, if necessary.

Definition at line 120 of file IFunction.h.

◆ Derivative() [2/2]

double ROOT::Math::IBaseFunctionMultiDimTempl< double >::Derivative ( const double * x,
unsigned int icoord = 0 ) const
inlineinherited

Return the partial derivative with respect to the passed coordinate.

Definition at line 115 of file IFunction.h.

◆ DoDerivative()

template<class Func>
double ROOT::Math::LSResidualFunc< Func >::DoDerivative ( const double * ,
unsigned int  ) const
inlineoverrideprivatevirtual

Function to evaluate the derivative with respect each coordinate. To be implemented by the derived class.

Reimplemented from ROOT::Math::IBaseFunctionMultiDimTempl< double >.

Definition at line 167 of file GSLNLSMinimizer.cxx.

◆ DoDerivativeWithPrevResult()

virtual double ROOT::Math::IBaseFunctionMultiDimTempl< double >::DoDerivativeWithPrevResult ( const double * x,
unsigned int icoord,
double * ,
double * ,
double *  ) const
inlineprivatevirtualinherited

In some cases, the derivative algorithm will use information from the previous step, these can be passed in with this overload.

The previous_* arrays can also be used to return second derivative and step size so that these can be passed forward again as well at the call site, if necessary.

Definition at line 136 of file IFunction.h.

◆ DoEval()

template<class Func>
double ROOT::Math::LSResidualFunc< Func >::DoEval ( const double * x) const
inlineoverrideprivatevirtual

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

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

Definition at line 165 of file GSLNLSMinimizer.cxx.

◆ FdF()

template<class Func>
void ROOT::Math::LSResidualFunc< Func >::FdF ( const double * x,
double & f,
double * df ) const
inlineoverridevirtual

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

Reimplemented from ROOT::Math::IBaseFunctionMultiDimTempl< double >.

Definition at line 162 of file GSLNLSMinimizer.cxx.

◆ Gradient()

template<class Func>
void ROOT::Math::LSResidualFunc< Func >::Gradient ( const double * x,
double * grad ) const
inlineoverridevirtual

Evaluate all the vector of function derivatives (gradient) at a point x.

Derived classes must re-implement it if more efficient than evaluating one at a time

Reimplemented from ROOT::Math::IBaseFunctionMultiDimTempl< double >.

Definition at line 154 of file GSLNLSMinimizer.cxx.

◆ HasGradient()

bool ROOT::Math::IGradientFunctionMultiDimTempl< double >::HasGradient ( ) const
inlineoverridevirtualinherited

Reimplemented from ROOT::Math::IBaseFunctionMultiDimTempl< double >.

Definition at line 243 of file IFunction.h.

◆ IsLSType()

template<class Func>
bool ROOT::Math::LSResidualFunc< Func >::IsLSType ( ) const
inline

Definition at line 160 of file GSLNLSMinimizer.cxx.

◆ NDim()

template<class Func>
unsigned int ROOT::Math::LSResidualFunc< Func >::NDim ( ) const
inlineoverridevirtual

Retrieve the dimension of the function.

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

Definition at line 152 of file GSLNLSMinimizer.cxx.

◆ operator()()

double ROOT::Math::IBaseFunctionMultiDimTempl< double >::operator() ( const double * 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 81 of file IFunction.h.

◆ operator=()

template<class Func>
LSResidualFunc< Func > & ROOT::Math::LSResidualFunc< Func >::operator= ( const LSResidualFunc< Func > & rhs)
inline

Definition at line 143 of file GSLNLSMinimizer.cxx.

Member Data Documentation

◆ fChi2

template<class Func>
const Func* ROOT::Math::LSResidualFunc< Func >::fChi2
private

Definition at line 175 of file GSLNLSMinimizer.cxx.

◆ fIndex

template<class Func>
unsigned int ROOT::Math::LSResidualFunc< Func >::fIndex
private

Definition at line 174 of file GSLNLSMinimizer.cxx.


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