Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
FcnAdapter.h
Go to the documentation of this file.
1// @(#)root/mathcore:$Id$
2// Author: L. Moneta 10/2005
3
4/**********************************************************************
5 * *
6 * Copyright (c) 2005 ROOT Foundation, CERN/PH-SFT *
7 * *
8 **********************************************************************/
9
10#ifndef ROOT_Fit_FcnAdapter_H_
11#define ROOT_Fit_FcnAdapter_H_
12
13#include "Math/IFunction.h"
14
15
16//___________________________________________________________
17//
18// Adapt the interface used in TMinuit (and the TVirtualFitter) for
19// passing the objective function in a IFunction interface
20// (ROOT::Math::IMultiGenFunction)
21//
22
23namespace ROOT {
24
25 namespace Fit {
26
28
29public:
30
31 FcnAdapter(void (*fcn)(int&, double*, double&, double*, int ), int dim = 0) :
32 fDim(dim),
33 fFCN(fcn)
34 {}
35
36 ~FcnAdapter() override {}
37
38 unsigned int NDim() const override { return fDim; }
39
41 return new FcnAdapter(fFCN,fDim);
42 }
43
44 void SetDimension(int dim) { fDim = dim; }
45
46private:
47
48 double DoEval(const double * x) const override {
49 double fval = 0;
50 int dim = fDim;
51 // call with flag 4
52 fFCN(dim, nullptr, fval, const_cast<double *>(x), 4);
53 return fval;
54 }
55
56private:
57
58 unsigned int fDim;
59 void (*fFCN)(int&, double*, double&, double*, int);
60
61};
62
63 } // end namespace Fit
64
65} // end namespace ROOT
66
67#endif //ROOT_Fit_FcnAdapter
ROOT::Math::IMultiGenFunction * Clone() const override
Clone a function.
Definition FcnAdapter.h:40
~FcnAdapter() override
Definition FcnAdapter.h:36
unsigned int NDim() const override
Retrieve the dimension of the function.
Definition FcnAdapter.h:38
void SetDimension(int dim)
Definition FcnAdapter.h:44
FcnAdapter(void(*fcn)(int &, double *, double &, double *, int), int dim=0)
Definition FcnAdapter.h:31
double DoEval(const double *x) const override
Definition FcnAdapter.h:48
void(* fFCN)(int &, double *, double &, double *, int)
Definition FcnAdapter.h:59
unsigned int fDim
Definition FcnAdapter.h:58
Documentation for the abstract class IBaseFunctionMultiDim.
Definition IFunction.h:61
Double_t x[n]
Definition legend1.C:17
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
Definition HFitImpl.cxx:133
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...