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 64 of file Polynomial.h.
Public Types | |
| typedef IParamGradFunction::BaseFunc | BaseFunc |
| typedef IGradientFunctionOneDim | BaseGradFunc |
| typedef IParametricFunctionOneDim | BaseParamFunc |
| typedef IParamGradFunction | BaseParFunc |
| typedef ParamFunction< IParamGradFunction > | ParFunc |
Public Member Functions | |
| Polynomial (double a, double b) | |
| Construct a Polynomial of degree 1 : a*x + b. | |
| Polynomial (double a, double b, double c) | |
| Construct a Polynomial of degree 2 : a*x**2 + b*x + c. | |
| Polynomial (double a, double b, double c, double d) | |
| Construct a Polynomial of degree 3 : a*x**3 + b*x**2 + c*x + d. | |
| 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. | |
| Polynomial (unsigned int n=0) | |
| Construct a Polynomial function of order n. | |
| ~Polynomial () override | |
| IGenFunction * | Clone () const override |
| Clone a function. | |
| double | Derivative (const double *x) const |
| Compatibility method with multi-dimensional interface for partial derivative. | |
| double | Derivative (double x) const |
| Return the derivative of the function at a point x Use the private method DoDerivative. | |
| void | FdF (const double *x, double &f, double *df) const |
| Compatibility method with multi-dimensional interface for Gradient and function evaluation. | |
| void | FdF (double x, double &f, double &df) const override |
| Optimized method to evaluate at the same time the function value and derivative at a point x. | |
| std::vector< std::complex< double > > | FindNumRoots () const |
| Find the polynomial roots using always an iterative numerical methods The numerical method used is from GSL (see documentation ). | |
| std::vector< double > | FindRealRoots () const |
| Find the only the real polynomial roots. | |
| std::vector< std::complex< double > > | FindRoots () const |
| Find the polynomial roots. | |
| void | Gradient (const double *x, double *g) const |
| Compatibility method with multi-dimensional interface for Gradient. | |
| virtual bool | HasGradient () const |
| bool | HasGradient () const override |
| unsigned int | NPar () const override |
| Return the number of parameters. | |
| double | operator() (const double *x) const |
| Evaluate the function at a point x[]. | |
| double | operator() (const double *x, const double *p) const |
| multidim-like interface | |
| double | operator() (double x) const |
| Evaluate the function at a point x. | |
| double | operator() (double x, const double *p) const |
| Evaluate function at a point x and for given parameters p. | |
| unsigned int | Order () const |
| Order of Polynomial. | |
| 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. | |
| double | ParameterDerivative (const double *x, unsigned int ipar=0) const |
| Evaluate partial derivative using cached parameter values (multi-dim like interface). | |
| double | ParameterDerivative (double x, const double *p, unsigned int ipar=0) const |
| Partial derivative with respect a parameter. | |
| double | ParameterDerivative (double x, unsigned int ipar=0) const |
| Evaluate partial derivative using cached parameter values. | |
| void | ParameterGradient (const double *x, const double *p, double *grad) const |
| Compatibility interface with multi-dimensional functions. | |
| void | ParameterGradient (const double *x, double *grad) const |
| Evaluate all derivatives using cached parameter values (multi-dim like interface). | |
| 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. | |
| void | ParameterGradient (double x, double *grad) const |
| Evaluate all derivatives using cached parameter values. | |
| 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, ..."). | |
| const double * | Parameters () const override |
| Access the parameter values. | |
| void | SetParameters (const double *p) override |
| Set the parameter values. | |
Protected Attributes | |
| std::vector< double > | fParams |
Private Member Functions | |
| double | DoDerivative (double x) const override |
| Function to evaluate the derivative with respect each coordinate. To be implemented by the derived class. | |
| double | DoEval (double x) const override |
| Implement the ROOT::Math::IBaseFunctionOneDim interface DoEval(x) using the cached parameter values. | |
| double | DoEvalPar (double x, const double *p) const override |
| Implementation of the evaluation function using the x value and the parameters. | |
| double | DoParameterDerivative (double x, const double *p, unsigned int ipar) const override |
| Evaluate the gradient, to be implemented by the derived classes. | |
Private Attributes | |
| std::vector< double > | fDerived_params |
| unsigned int | fNpar |
| Return true if the calculation of derivatives is implemented. | |
| unsigned int | fOrder |
#include <Math/Polynomial.h>
|
inherited |
Definition at line 72 of file ParamFunction.h.
Definition at line 335 of file IParamFunction.h.
|
inherited |
Definition at line 334 of file IParamFunction.h.
|
inherited |
Definition at line 71 of file ParamFunction.h.
Definition at line 71 of file Polynomial.h.
| 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 49 of file Polynomial.cxx.
Construct a Polynomial of degree 1 : a*x + b.
Definition at line 58 of file Polynomial.cxx.
Construct a Polynomial of degree 2 : a*x**2 + b*x + c.
Definition at line 68 of file Polynomial.cxx.
Construct a Polynomial of degree 3 : a*x**3 + b*x**2 + c*x + d.
Definition at line 79 of file Polynomial.cxx.
Construct a Polynomial of degree 4 : a*x**4 + b*x**3 + c*x**2 + dx + e.
Definition at line 92 of file Polynomial.cxx.
|
inlineoverride |
Definition at line 100 of file Polynomial.h.
|
overridevirtual |
Clone a function.
Each derived class will implement their version of the private DoClone method.
Implements ROOT::Math::IBaseFunctionOneDim.
Definition at line 143 of file Polynomial.cxx.
Compatibility method with multi-dimensional interface for partial derivative.
Definition at line 186 of file IFunction.h.
Return the derivative of the function at a point x Use the private method DoDerivative.
Definition at line 183 of file IFunction.h.
Function to evaluate the derivative with respect each coordinate. To be implemented by the derived class.
Reimplemented from ROOT::Math::IBaseFunctionOneDim.
Definition at line 127 of file Polynomial.cxx.
|
inlineoverrideprivatevirtualinherited |
Implement the ROOT::Math::IBaseFunctionOneDim interface DoEval(x) using the cached parameter values.
Implements ROOT::Math::IBaseFunctionOneDim.
Reimplemented in ROOT::Math::VavilovAccurateCdf, ROOT::Math::VavilovAccuratePdf, ROOT::Math::VavilovAccurateQuantile, and ROOT::Math::WrappedTF1.
Definition at line 203 of file IParamFunction.h.
|
overrideprivatevirtual |
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 119 of file Polynomial.cxx.
|
overrideprivatevirtual |
Evaluate the gradient, to be implemented by the derived classes.
Implements ROOT::Math::IParametricGradFunctionOneDim.
Definition at line 136 of file Polynomial.cxx.
|
inlineinherited |
Compatibility method with multi-dimensional interface for Gradient and function evaluation.
Definition at line 202 of file IFunction.h.
Optimized method to evaluate at the same time the function value and derivative at a point x.
Implement the interface specified by ROOT::Math::IGradientOneDim. In the case of polynomial there is no advantage to compute both at the same time
Reimplemented from ROOT::Math::IBaseFunctionOneDim.
Definition at line 147 of file Polynomial.h.
| std::vector< std::complex< double > > ROOT::Math::Polynomial::FindNumRoots | ( | ) | const |
Find the polynomial roots using always an iterative numerical methods The numerical method used is from GSL (see documentation ).
Definition at line 240 of file Polynomial.cxx.
| std::vector< double > ROOT::Math::Polynomial::FindRealRoots | ( | ) | const |
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 documentation )
Definition at line 230 of file Polynomial.cxx.
| std::vector< std::complex< double > > ROOT::Math::Polynomial::FindRoots | ( | ) | const |
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 documentation ) For the case of n = 4 by default an analytical algorithm is used from an implementation by Andrew W. Steiner and Andy Buckley which is a translation from the original Cenrlib routine (< HREF="https://cds.cern.ch/record/2050876/files/c208.html">RRTEQ4 ). Note that depending on the coefficients the result could be not very accurate if the discriminant of the resolvent cubic equation is very small. In that case it might be more robust to use the numerical method, by calling directly FindNumRoots()
Definition at line 150 of file Polynomial.cxx.
|
inlineinherited |
Compatibility method with multi-dimensional interface for Gradient.
Definition at line 189 of file IFunction.h.
|
inlinevirtualinherited |
Reimplemented in ROOT::Math::IGradientFunctionOneDim.
Definition at line 179 of file IFunction.h.
|
inlineoverridevirtualinherited |
Reimplemented from ROOT::Math::IBaseFunctionOneDim.
Definition at line 266 of file IFunction.h.
|
inlineoverridevirtualinherited |
Return the number of parameters.
Implements ROOT::Math::IBaseParam.
Definition at line 112 of file ParamFunction.h.
Evaluate the function at a point x[].
Compatible method with multi-dimensional functions.
Definition at line 169 of file IFunction.h.
|
inlineinherited |
multidim-like interface
Definition at line 187 of file IParamFunction.h.
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 169 of file IFunction.h.
|
inlineinherited |
Evaluate function at a point x and for given parameters p.
This method does not change the internal status of the function (internal parameter values). If for some reason one prefers caching the parameter values, SetParameters(p) and then operator()(x) should be called. Use the pure virtual function DoEvalPar to implement it
Definition at line 178 of file IParamFunction.h.
|
inline |
Order of Polynomial.
Definition at line 137 of file Polynomial.h.
|
inlineinherited |
Partial derivative with respect a parameter Compatibility interface with multi-dimensional functions.
Definition at line 403 of file IParamFunction.h.
|
inlineinherited |
Evaluate partial derivative using cached parameter values (multi-dim like interface).
Definition at line 412 of file IParamFunction.h.
|
inlineinherited |
Partial derivative with respect a parameter.
Definition at line 386 of file IParamFunction.h.
|
inlineinherited |
Evaluate partial derivative using cached parameter values.
Definition at line 394 of file IParamFunction.h.
|
inlineinherited |
Compatibility interface with multi-dimensional functions.
Definition at line 369 of file IParamFunction.h.
|
inlineinherited |
Evaluate all derivatives using cached parameter values (multi-dim like interface).
Definition at line 377 of file IParamFunction.h.
|
inlinevirtualinherited |
Evaluate the derivatives of the function with respect to the parameters at a point x.
It is optional to be implemented by the derived classes for better efficiency if needed
Reimplemented in ROOT::Math::WrappedTF1.
Definition at line 351 of file IParamFunction.h.
|
inlineinherited |
Evaluate all derivatives using cached parameter values.
Definition at line 361 of file IParamFunction.h.
|
inlinevirtualinherited |
Return the name of the i-th parameter (starting from zero) Overwrite if want to avoid the default name ("Par_0, Par_1, ...").
Reimplemented in ROOT::Math::VavilovAccurateCdf, ROOT::Math::VavilovAccuratePdf, ROOT::Math::VavilovAccurateQuantile, ROOT::Math::WrappedMultiTF1Templ< T >, ROOT::Math::WrappedMultiTF1Templ< double >, and ROOT::Math::WrappedTF1.
Definition at line 86 of file IParamFunction.h.
|
inlineoverridevirtualinherited |
Access the parameter values.
Implements ROOT::Math::IBaseParam.
Definition at line 96 of file ParamFunction.h.
|
inlineoverridevirtualinherited |
Set the parameter values.
| p | vector of doubles containing the parameter values. |
Implements ROOT::Math::IBaseParam.
Definition at line 102 of file ParamFunction.h.
|
mutableprivate |
Definition at line 166 of file Polynomial.h.
|
privateinherited |
Return true if the calculation of derivatives is implemented.
Return true if the calculation of derivatives with respect to the Parameters is implemented
Definition at line 137 of file ParamFunction.h.
|
private |
Definition at line 163 of file Polynomial.h.
|
protectedinherited |
Definition at line 142 of file ParamFunction.h.