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 virtual ~FcnAdapter() {}
37
38 virtual unsigned int NDim() const { return fDim; }
39
41 return new FcnAdapter(fFCN,fDim);
42 }
43
44 void SetDimension(int dim) { fDim = dim; }
45
46private:
47
48 virtual double DoEval(const double * x) const {
49 double fval = 0;
50 int dim = fDim;
51 // call with flag 4
52 fFCN(dim, 0, 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
64 } // end namespace Fit
65
66} // end namespace ROOT
67
68#endif //ROOT_Fit_FcnAdapter
typedef void((*Func_t)())
virtual unsigned int NDim() const
Retrieve the dimension of the function.
Definition FcnAdapter.h:38
virtual double DoEval(const double *x) const
Definition FcnAdapter.h:48
ROOT::Math::IMultiGenFunction * Clone() const
Clone a function.
Definition FcnAdapter.h:40
void SetDimension(int dim)
Definition FcnAdapter.h:44
FcnAdapter(void(*fcn)(int &, double *, double &, double *, int), int dim=0)
Definition FcnAdapter.h:31
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:62
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...