Logo ROOT   6.08/07
Reference Guide
FCNGradAdapter.h
Go to the documentation of this file.
1 // @(#)root/minuit2:$Id$
2 // Author: L. Moneta 10/2006
3 
4 /**********************************************************************
5  * *
6  * Copyright (c) 2006 ROOT Foundation, CERN/PH-SFT *
7  * *
8  **********************************************************************/
9 
10 #ifndef ROOT_Minuit2_FCNGradAdapter
11 #define ROOT_Minuit2_FCNGradAdapter
12 
13 #ifndef ROOT_Minuit2_FCNGradientBase
15 #endif
16 
17 //#define DEBUG
18 #ifdef DEBUG
19 #include <iostream>
20 #endif
21 
22 namespace ROOT {
23 
24  namespace Minuit2 {
25 
26 /**
27 
28 
29 template wrapped class for adapting to FCNBase signature a IGradFunction
30 
31 @author Lorenzo Moneta
32 
33 @ingroup Minuit
34 
35 */
36 
37 template< class Function>
39 
40 public:
41 
42  FCNGradAdapter(const Function & f, double up = 1.) :
43  fFunc(f) ,
44  fUp (up) ,
45  fGrad(std::vector<double>(fFunc.NDim() ) )
46 
47  {}
48 
50 
51 
52  double operator()(const std::vector<double>& v) const {
53  return fFunc.operator()(&v[0]);
54  }
55  double operator()(const double * v) const {
56  return fFunc.operator()(v);
57  }
58 
59  double Up() const {return fUp;}
60 
61  std::vector<double> Gradient(const std::vector<double>& v) const {
62  fFunc.Gradient(&v[0], &fGrad[0]);
63 
64 #ifdef DEBUG
65  std::cout << " gradient in FCNAdapter = { " ;
66  for (unsigned int i = 0; i < fGrad.size(); ++i)
67  std::cout << fGrad[i] << "\t";
68  std::cout << "}" << std::endl;
69 #endif
70  return fGrad;
71  }
72  // forward interface
73  //virtual double operator()(int npar, double* params,int iflag = 4) const;
74  bool CheckGradient() const { return false; }
75 
76 private:
77  const Function & fFunc;
78  double fUp;
79  mutable std::vector<double> fGrad;
80 };
81 
82  } // end namespace Minuit2
83 
84 } // end namespace ROOT
85 
86 
87 
88 #endif //ROOT_Minuit2_FCNGradAdapter
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
Definition: StringConv.hxx:21
double operator()(const std::vector< double > &v) const
The meaning of the vector of parameters is of course defined by the user, who uses the values of thos...
double operator()(const double *v) const
STL namespace.
template wrapped class for adapting to FCNBase signature a IGradFunction
Extension of the FCNBase for providing the analytical Gradient of the function.
std::vector< double > Gradient(const std::vector< double > &v) const
SVector< double, 2 > v
Definition: Dict.h:5
FCNGradAdapter(const Function &f, double up=1.)
double f(double x)
std::vector< double > fGrad
double Up() const
Error definition of the function.