Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
ParametricFunction.cxx
Go to the documentation of this file.
1 // @(#)root/minuit2:$Id$
2 // Authors: M. Winkler, F. James, L. Moneta, A. Zsenei 2003-2005
3 
4 /**********************************************************************
5  * *
6  * Copyright (c) 2005 LCG ROOT Math team, CERN/PH-SFT *
7  * *
8  **********************************************************************/
9 
11 #include "Minuit2/MnFcn.h"
12 #include "Minuit2/MnStrategy.h"
17 
18 namespace ROOT {
19 
20  namespace Minuit2 {
21 
22 //#include "Minuit2/MnPrint.h"
23 
24 
25 
26 std::vector<double> ParametricFunction::GetGradient(const std::vector<double>& x) const {
27  // calculate the numerical gradient (using Numerical2PGradientCalculator)
28 
29  //LM: this I believe is not very efficient
30  MnFcn mfcn(*this);
31 
32  MnStrategy strategy(1);
33 
34  // ????????? how does it know the transformation????????
35  std::vector<double> err(x.size());
36  err.assign(x.size(), 0.1);
37  // need to use parameters
38  MnUserParameterState st(x, err);
39 
40  Numerical2PGradientCalculator gc(mfcn, st.Trafo(), strategy);
41  FunctionGradient g = gc(x);
42  const MnAlgebraicVector & grad = g.Vec();
43  assert( grad.size() == x.size() );
44  MnVectorTransform vt;
45  // std::cout << "Param Function Gradient " << grad << std::endl;
46  return vt( grad );
47 }
48 
49  } // namespace Minuit2
50 
51 } // namespace ROOT