13#ifndef ROOT_Math_WrappedMultiTF1
14#define ROOT_Math_WrappedMultiTF1
94 unsigned int NDim()
const override
114 unsigned int NPar()
const override
206 Error(
"DoParameterDerivative",
"The vectorized implementation of DoParameterDerivative does not support"
207 "general linear functions built in TFormula with ++");
219 assert(df !=
nullptr);
220 return (
const_cast<TFormula *
>(df))->EvalPar(
x);
246 while (
fLinear && ip < fFunc->GetNpar()) {
261 fLinear(rhs.fLinear),
262 fPolynomial(rhs.fPolynomial),
263 fOwnFunc(rhs.fOwnFunc),
276 if (
this == &rhs)
return *
this;
295 fFunc->SetParameters(par);
297 double prec = this->GetDerivPrecision();
298 fFunc->GradientPar(
x, grad, prec);
300 unsigned int np = NPar();
301 for (
unsigned int i = 0; i <
np; ++i)
302 grad[i] = DoParameterDerivative(
x, par, i);
311 Error(
"Hessian",
"The vectorized implementation of ParameterHessian is not supported");
319 static bool Hessian(
TF1 * func,
const double *
x,
const double * par,
double *
h)
324 if (!formula)
return false;
325 std::vector<double> h2(
np*
np);
327 formula->HessianPar(
x,h2);
328 for (
unsigned int i = 0; i <
np; i++) {
329 for (
unsigned int j = 0; j <= i; j++) {
330 unsigned int ih = j + i *(i+1)/2;
331 unsigned int im = i*
np + j;
339 if (!formula)
return false;
350 std::fill(
h,
h + NPar()*(NPar()+1)/2, 0.0);
368 fFunc->SetParameters(
p);
369 double prec = this->GetDerivPrecision();
370 return fFunc->GradientPar(ipar,
x, prec);
375 if (ipar == 0)
return 1.0;
377 return vecCore::math::Pow(
x[0],
static_cast<T
>(ipar));
379 return std::pow(
x[0],
static_cast<int>(ipar));
395 return ::ROOT::Math::Internal::DerivPrecision(-1);
401 const TF1 *funcToCopy = (
f) ?
f : fFunc;
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
Documentation for the abstract class IBaseFunctionMultiDim.
Interface (abstract class) for parametric gradient multi-dimensional functions providing in addition ...
Class to Wrap a ROOT Function class (like TF1) in a IParamMultiFunction interface of multi-dimensions...
void SetAndCopyFunction(const TF1 *f=nullptr)
method to set a new function pointer and copy it inside.
T DoParameterDerivative(const T *x, const double *p, unsigned int ipar) const override
evaluate the partial derivative with respect to the parameter
bool HasParameterHessian() const override
~WrappedMultiTF1Templ() override
Destructor (no operations).
const double * Parameters() const override
get the parameter values (return values from TF1)
T DoEval(const T *x) const override
evaluate function using the cached parameter values (of TF1) re-implement for better efficiency
bool ParameterG2(const T *, const double *, T *) const override
Evaluate all the second derivatives (diagonal ones) of the function with respect to the parameters at...
static void SetDerivPrecision(double eps)
precision value used for calculating the derivative step-size h = eps * |x|.
static double GetDerivPrecision()
get precision value used for calculating the derivative step-size
ROOT::Math::IParametricGradFunctionMultiDimTempl< T > BaseParamFunc
WrappedMultiTF1Templ & operator=(const WrappedMultiTF1Templ< T > &rhs)
Assignment operator.
std::string ParameterName(unsigned int i) const override
return parameter name (from TF1)
const TF1 * GetFunction() const
method to retrieve the internal function pointer
unsigned int NDim() const override
Retrieve the dimension of the function.
unsigned int NPar() const override
return number of parameters
IMultiGenFunctionTempl< T > * Clone() const override
Clone the wrapper but not the original function.
void SetParameters(const double *p) override
set parameter values (only the cached one in this class,leave unchanges those of TF1)
void ParameterGradient(const T *x, const double *par, T *grad) const override
Evaluate the all the derivatives (gradient vector) of the function with respect to the parameters at ...
ROOT::Math::IParametricFunctionMultiDimTempl< T >::BaseFunc BaseFunc
T DoEvalVec(const T *x) const
evaluate function using the cached parameter values (of TF1) re-implement for better efficiency
T DoEvalPar(const T *x, const double *p) const override
evaluate function passing coordinates x and vector of parameters
WrappedMultiTF1Templ(TF1 &f, unsigned int dim=0)
constructor from a function pointer to a TF1 If dim = 0 dimension is taken from TF1::GetNdim().
bool ParameterHessian(const T *x, const double *par, T *h) const override
Evaluate the all the Hessian (second derivatives matrix) of the function with respect to the paramete...
virtual Int_t GetNumber() const
virtual Int_t GetNpar() const
virtual Double_t * GetParameters() const
virtual TFormula * GetFormula()
virtual const char * GetParName(Int_t ipar) const
virtual Double_t EvalPar(const Double_t *x, const Double_t *params=nullptr)
Evaluate function with given coordinates and parameters.
virtual Bool_t IsLinear() const
virtual void SetParameters(const Double_t *params)
virtual Int_t GetNdim() const
virtual const TObject * GetLinearPart(Int_t i) const
Namespace for new Math classes and functions.
double DerivPrecision(double eps)
TF1 * CopyTF1Ptr(const TF1 *funcToCopy)
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
Double_t SignalingNaN()
Returns a signaling NaN as defined by IEEE 754](http://en.wikipedia.org/wiki/NaN#Signaling_NaN).
static bool IsAvailable(TF1 *func)
static bool Hessian(TF1 *func, const double *x, const double *par, double *h)
static bool Hessian(TF1 *, const T *, const double *, T *)
static bool IsAvailable(TF1 *)
static double DoParameterDerivative(const WrappedMultiTF1Templ< double > *wrappedFunc, const double *x, unsigned int ipar)
Auxiliar class to bypass the (provisional) lack of vectorization in TFormula::EvalPar.
static T DoParameterDerivative(const WrappedMultiTF1Templ< T > *, const T *, unsigned int)