Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
FCNAdapter.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_FCNAdapter
11 #define ROOT_Minuit2_FCNAdapter
12 
13 #include "Minuit2/FCNBase.h"
14 
15 namespace ROOT {
16 
17  namespace Minuit2 {
18 
19 /**
20 
21 
22 template wrapped class for adapting to FCNBase signature
23 
24 @author Lorenzo Moneta
25 
26 @ingroup Minuit
27 
28 */
29 
30 template< class Function>
31 class FCNAdapter : public FCNBase {
32 
33 public:
34 
35  FCNAdapter(const Function & f, double up = 1.) :
36  fFunc(f) ,
37  fUp (up)
38  {}
39 
40  ~FCNAdapter() {}
41 
42 
43  double operator()(const std::vector<double>& v) const {
44  return fFunc.operator()(&v[0]);
45  }
46  double operator()(const double * v) const {
47  return fFunc.operator()(v);
48  }
49  double Up() const {return fUp;}
50 
51  void SetErrorDef(double up) { fUp = up; }
52 
53  //virtual std::vector<double> Gradient(const std::vector<double>&) const;
54 
55  // forward interface
56  //virtual double operator()(int npar, double* params,int iflag = 4) const;
57 
58 private:
59  const Function & fFunc;
60  double fUp;
61 };
62 
63  } // end namespace Minuit2
64 
65 } // end namespace ROOT
66 
67 
68 
69 #endif //ROOT_Minuit2_FCNAdapter