Logo ROOT   6.08/07
Reference Guide
AnalyticalGradientCalculator.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 
15 #include "Minuit2/MnMatrix.h"
16 
17 namespace ROOT {
18  namespace Minuit2 {
19 
20 
22  // evaluate analytical gradient. take care of parameter transformations
23 
24  std::vector<double> grad = fGradCalc.Gradient(fTransformation(par.Vec()));
25  assert(grad.size() == fTransformation.Parameters().size());
26 
27  MnAlgebraicVector v(par.Vec().size());
28  for(unsigned int i = 0; i < par.Vec().size(); i++) {
29  unsigned int ext = fTransformation.ExtOfInt(i);
31  //double dd = (fTransformation.Parameter(ext).Upper() - fTransformation.Parameter(ext).Lower())*0.5*cos(par.Vec()(i));
32  // const ParameterTransformation * pt = fTransformation.transformation(ext);
33  // double dd = pt->dInt2ext(par.Vec()(i), fTransformation.Parameter(ext).Lower(), fTransformation.Parameter(ext).Upper() );
34  double dd = fTransformation.DInt2Ext(i, par.Vec()(i));
35  v(i) = dd*grad[ext];
36  } else {
37  v(i) = grad[ext];
38  }
39  }
40 
41  return FunctionGradient(v);
42 }
43 
45  // needed from base class
46  return (*this)(par);
47 }
48 
50  // check to be sure FCN implements analytical gradient
51  return fGradCalc.CheckGradient();
52 }
53 
54  } // namespace Minuit2
55 
56 } // namespace ROOT
double par[1]
Definition: unuranDistr.cxx:38
virtual bool CheckGradient() const
virtual std::vector< double > Gradient(const std::vector< double > &) const =0
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
Definition: StringConv.hxx:21
const MnAlgebraicVector & Vec() const
double DInt2Ext(unsigned int, double) const
unsigned int ExtOfInt(unsigned int internal) const
SVector< double, 2 > v
Definition: Dict.h:5
unsigned int size() const
Definition: LAVector.h:198
const std::vector< MinuitParameter > & Parameters() const
virtual FunctionGradient operator()(const MinimumParameters &) const
const MinuitParameter & Parameter(unsigned int) const