13#ifndef ROOT_Math_WrappedMultiTF1
14#define ROOT_Math_WrappedMultiTF1
94 unsigned int NDim()
const override
103 return fFunc->GetParameters();
110 fFunc->SetParameters(p);
114 unsigned int NPar()
const override
117 return fFunc->GetNpar();
122 return std::string(
fFunc->GetParName(i));
160 return fFunc->EvalPar(
x, p);
167 return fFunc->EvalPar(
x, 0);
178 return fFunc->EvalPar(
x,
nullptr);
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()) {
247 fLinear &= (fFunc->GetLinearPart(ip) != nullptr);
252 if (fDim == 1 && fFunc->GetNumber() >= 300 && fFunc->GetNumber() < 310) {
276 if (
this == &rhs)
return *
this;
295 fFunc->SetParameters(par);
298 fFunc->GradientPar(
x, grad, prec);
300 unsigned int np =
NPar();
301 for (
unsigned int i = 0; i < np; ++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)
322 unsigned int np = func->
GetNpar();
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;
368 fFunc->SetParameters(p);
370 return fFunc->GradientPar(ipar,
x, prec);
375 if (ipar == 0)
return 1.0;
376 return pow(
x[0],
static_cast<int>(ipar));
391 return ::ROOT::Math::Internal::DerivPrecision(-1);
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
IBaseFunctionMultiDimTempl< T > BaseFunc
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).
WrappedMultiTF1Templ(const WrappedMultiTF1Templ< T > &rhs)
Copy constructor.
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 GetNpar() const
virtual TFormula * GetFormula()
virtual void SetParameters(const Double_t *params)
if(pos!=-1) leafTypeName.Remove(pos)
double DerivPrecision(double eps)
TF1 * CopyTF1Ptr(const TF1 *funcToCopy)
WrappedMultiTF1Templ< double > WrappedMultiTF1
IBaseFunctionMultiDimTempl< T > IMultiGenFunctionTempl
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)