ROOT  6.06/09
Reference Guide
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members

Parametric Function class describing polynomials of order n.

P(x) = p[0] + p[1]*x + p[2]*x**2 + ....... + p[n]*x**n

The class implements also the derivatives, dP(x)/dx and the dP(x)/dp[i].

The class provides also the method to find the roots of the polynomial. It uses analytical methods up to quartic polynomials.

Implements both the Parameteric function interface and the gradient interface since it provides the analytical gradient with respect to x

Definition at line 63 of file Polynomial.h.

Public Types

typedef ParamFunction< IParamGradFunctionParFunc
 
- Public Types inherited from ROOT::Math::ParamFunction< IParamGradFunction >
typedef IParamGradFunction BaseParFunc
 
typedef IParamGradFunction::BaseFunc BaseFunc
 
- Public Types inherited from ROOT::Math::IParametricGradFunctionOneDim
typedef IParametricFunctionOneDim BaseParamFunc
 
typedef IGradientFunctionOneDim BaseGradFunc
 
typedef IParametricFunctionOneDim::BaseFunc BaseFunc
 
- Public Types inherited from ROOT::Math::IParametricFunctionOneDim
typedef IBaseFunctionOneDim BaseFunc
 
- Public Types inherited from ROOT::Math::IBaseFunctionOneDim
typedef IBaseFunctionOneDim BaseFunc
 

Public Member Functions

 Polynomial (unsigned int n=0)
 Construct a Polynomial function of order n. More...
 
 Polynomial (double a, double b)
 Construct a Polynomial of degree 1 : a*x + b. More...
 
 Polynomial (double a, double b, double c)
 Construct a Polynomial of degree 2 : a*x**2 + b*x + c. More...
 
 Polynomial (double a, double b, double c, double d)
 Construct a Polynomial of degree 3 : a*x**3 + b*x**2 + c*x + d. More...
 
 Polynomial (double a, double b, double c, double d, double e)
 Construct a Polynomial of degree 4 : a*x**4 + b*x**3 + c*x**2 + dx + e. More...
 
virtual ~Polynomial ()
 
const std::vector< std::complex< double > > & FindRoots ()
 Find the polynomial roots. More...
 
std::vector< doubleFindRealRoots ()
 Find the only the real polynomial roots. More...
 
const std::vector< std::complex< double > > & FindNumRoots ()
 Find the polynomial roots using always an iterative numerical methods The numerical method used is from GSL (see <A HREF="http://www.gnu.org/software/gsl/manual/gsl-ref_6.html#SEC53" ) More...
 
unsigned int Order () const
 Order of Polynomial. More...
 
IGenFunctionClone () const
 Clone a function. More...
 
void FdF (double x, double &f, double &df) const
 Optimized method to evaluate at the same time the function value and derivative at a point x. More...
 
- Public Member Functions inherited from ROOT::Math::ParamFunction< IParamGradFunction >
 ParamFunction (unsigned int npar=0)
 Construct a parameteric function with npar parameters. More...
 
virtual ~ParamFunction ()
 
virtual const doubleParameters () const
 Access the parameter values. More...
 
virtual void SetParameters (const double *p)
 Set the parameter values. More...
 
unsigned int NPar () const
 Return the number of parameters. More...
 
- Public Member Functions inherited from ROOT::Math::IParametricGradFunctionOneDim
virtual ~IParametricGradFunctionOneDim ()
 Virtual Destructor (no operations) More...
 
virtual void ParameterGradient (double x, const double *p, double *grad) const
 Evaluate the derivatives of the function with respect to the parameters at a point x. More...
 
void ParameterGradient (double x, double *grad) const
 Evaluate all derivatives using cached parameter values. More...
 
void ParameterGradient (const double *x, const double *p, double *grad) const
 Compatibility interface with multi-dimensional functions. More...
 
void ParameterGradient (const double *x, double *grad) const
 Evaluate all derivatives using cached parameter values (multi-dim like interface) More...
 
double ParameterDerivative (double x, const double *p, unsigned int ipar=0) const
 Partial derivative with respect a parameter. More...
 
double ParameterDerivative (double x, unsigned int ipar=0) const
 Evaluate partial derivative using cached parameter values. More...
 
double ParameterDerivative (const double *x, const double *p, unsigned int ipar=0) const
 Partial derivative with respect a parameter Compatibility interface with multi-dimensional functions. More...
 
double ParameterDerivative (const double *x, unsigned int ipar=0) const
 Evaluate partial derivative using cached parameter values (multi-dim like interface) More...
 
- Public Member Functions inherited from ROOT::Math::IParametricFunctionOneDim
double operator() (double x, const double *p) const
 Evaluate function at a point x and for given parameters p. More...
 
double operator() (const double *x, const double *p) const
 multidim-like interface More...
 
- Public Member Functions inherited from ROOT::Math::IBaseFunctionOneDim
 IBaseFunctionOneDim ()
 
virtual ~IBaseFunctionOneDim ()
 virtual destructor More...
 
double operator() (double x) const
 Evaluate the function at a point x Use the a pure virtual private method DoEval which must be implemented by sub-classes. More...
 
double operator() (const double *x) const
 Evaluate the function at a point x[]. More...
 
- Public Member Functions inherited from ROOT::Math::IBaseParam
virtual ~IBaseParam ()
 Virtual Destructor (no operations) More...
 
virtual std::string ParameterName (unsigned int i) const
 Return the name of the i-th parameter (starting from zero) Overwrite if want to avoid the default name ("Par_0, Par_1, ...") More...
 
- Public Member Functions inherited from ROOT::Math::IGradientOneDim
virtual ~IGradientOneDim ()
 virtual destructor More...
 
double Derivative (double x) const
 Return the derivative of the function at a point x Use the private method DoDerivative. More...
 
double Derivative (const double *x) const
 Compatibility method with multi-dimensional interface for partial derivative. More...
 
void Gradient (const double *x, double *g) const
 Compatibility method with multi-dimensional interface for Gradient. More...
 
void FdF (const double *x, double &f, double *df) const
 Compatibility method with multi-dimensional interface for Gradient and function evaluation. More...
 

Private Member Functions

double DoEvalPar (double x, const double *p) const
 Implementation of the evaluation function using the x value and the parameters. More...
 
double DoDerivative (double x) const
 function to evaluate the derivative with respect each coordinate. More...
 
double DoParameterDerivative (double x, const double *p, unsigned int ipar) const
 Evaluate the gradient, to be implemented by the derived classes. More...
 

Private Attributes

unsigned int fOrder
 
std::vector< doublefDerived_params
 
std::vector< std::complex< double > > fRoots
 

Additional Inherited Members

- Protected Attributes inherited from ROOT::Math::ParamFunction< IParamGradFunction >
std::vector< doublefParams
 

#include <Math/Polynomial.h>

+ Inheritance diagram for ROOT::Math::Polynomial:
+ Collaboration diagram for ROOT::Math::Polynomial:

Member Typedef Documentation

Definition at line 70 of file Polynomial.h.

Constructor & Destructor Documentation

ROOT::Math::Polynomial::Polynomial ( unsigned int  n = 0)

Construct a Polynomial function of order n.

The number of Parameters is n+1.

Definition at line 50 of file Polynomial.cxx.

Referenced by Clone().

ROOT::Math::Polynomial::Polynomial ( double  a,
double  b 
)

Construct a Polynomial of degree 1 : a*x + b.

Definition at line 59 of file Polynomial.cxx.

ROOT::Math::Polynomial::Polynomial ( double  a,
double  b,
double  c 
)

Construct a Polynomial of degree 2 : a*x**2 + b*x + c.

Definition at line 69 of file Polynomial.cxx.

ROOT::Math::Polynomial::Polynomial ( double  a,
double  b,
double  c,
double  d 
)

Construct a Polynomial of degree 3 : a*x**3 + b*x**2 + c*x + d.

Definition at line 80 of file Polynomial.cxx.

ROOT::Math::Polynomial::Polynomial ( double  a,
double  b,
double  c,
double  d,
double  e 
)

Construct a Polynomial of degree 4 : a*x**4 + b*x**3 + c*x**2 + dx + e.

Definition at line 93 of file Polynomial.cxx.

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

Definition at line 99 of file Polynomial.h.

Member Function Documentation

IGenFunction * ROOT::Math::Polynomial::Clone ( ) const
virtual

Clone a function.

Each derived class will implement their version of the provate DoClone method

Implements ROOT::Math::IBaseFunctionOneDim.

Definition at line 144 of file Polynomial.cxx.

double ROOT::Math::Polynomial::DoDerivative ( double  x) const
privatevirtual

function to evaluate the derivative with respect each coordinate.

To be implemented by the derived class

Implements ROOT::Math::IGradientOneDim.

Definition at line 128 of file Polynomial.cxx.

double ROOT::Math::Polynomial::DoEvalPar ( double  x,
const double p 
) const
privatevirtual

Implementation of the evaluation function using the x value and the parameters.

Must be implemented by derived classes

Implements ROOT::Math::IParametricFunctionOneDim.

Definition at line 120 of file Polynomial.cxx.

double ROOT::Math::Polynomial::DoParameterDerivative ( double  x,
const double p,
unsigned int  ipar 
) const
privatevirtual

Evaluate the gradient, to be implemented by the derived classes.

Implements ROOT::Math::IParametricGradFunctionOneDim.

Definition at line 137 of file Polynomial.cxx.

void ROOT::Math::Polynomial::FdF ( double  x,
double f,
double df 
) const
inlinevirtual

Optimized method to evaluate at the same time the function value and derivative at a point x.

Implement the interface specified bby ROOT::Math::IGradientOneDim. In the case of polynomial there is no advantage to compute both at the same time

Implements ROOT::Math::IGradientOneDim.

Definition at line 143 of file Polynomial.h.

const std::vector< std::complex< double > > & ROOT::Math::Polynomial::FindNumRoots ( )

Find the polynomial roots using always an iterative numerical methods The numerical method used is from GSL (see <A HREF="http://www.gnu.org/software/gsl/manual/gsl-ref_6.html#SEC53" )

Definition at line 248 of file Polynomial.cxx.

Referenced by FindRoots().

std::vector< double > ROOT::Math::Polynomial::FindRealRoots ( )

Find the only the real polynomial roots.

For n <= 4, the roots are found analytically while for larger order an iterative numerical method is used The numerical method used is from GSL (see <A HREF="http://www.gnu.org/software/gsl/manual/gsl-ref_6.html#SEC53" )

Definition at line 238 of file Polynomial.cxx.

const std::vector< std::complex< double > > & ROOT::Math::Polynomial::FindRoots ( )

Find the polynomial roots.

For n <= 4, the roots are found analytically while for larger order an iterative numerical method is used The numerical method used is from GSL (see <A HREF="http://www.gnu.org/software/gsl/manual/gsl-ref_6.html#SEC53" )

Definition at line 152 of file Polynomial.cxx.

Referenced by FindRealRoots().

unsigned int ROOT::Math::Polynomial::Order ( ) const
inline

Order of Polynomial.

Definition at line 133 of file Polynomial.h.

Member Data Documentation

std::vector<double> ROOT::Math::Polynomial::fDerived_params
mutableprivate

Definition at line 162 of file Polynomial.h.

Referenced by Clone(), and DoDerivative().

unsigned int ROOT::Math::Polynomial::fOrder
private

Definition at line 159 of file Polynomial.h.

Referenced by Clone(), DoDerivative(), DoEvalPar(), FindNumRoots(), FindRealRoots(), FindRoots(), and Order().

std::vector< std::complex < double > > ROOT::Math::Polynomial::fRoots
private

Definition at line 166 of file Polynomial.h.

Referenced by FindNumRoots(), FindRealRoots(), and FindRoots().


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