// @(#)root/minuit2:$Id$ // Authors: M. Winkler, F. James, L. Moneta, A. Zsenei 2003-2005 /********************************************************************** * * * Copyright (c) 2005 LCG ROOT Math team, CERN/PH-SFT * * * **********************************************************************/ #include "Minuit2/DavidonErrorUpdator.h" #include "Minuit2/MinimumState.h" #include "Minuit2/LaSum.h" #include "Minuit2/LaProd.h" //#define DEBUG #if defined(DEBUG) || defined(WARNINGMSG) #include "Minuit2/MnPrint.h" #endif namespace ROOT { namespace Minuit2 { double inner_product(const LAVector&, const LAVector&); double similarity(const LAVector&, const LASymMatrix&); double sum_of_elements(const LASymMatrix&); MinimumError DavidonErrorUpdator::Update(const MinimumState& s0, const MinimumParameters& p1, const FunctionGradient& g1) const { // update of the covarianze matrix (Davidon formula, see Tutorial, par. 4.8 pag 26) // in case of delgam > gvg (PHI > 1) use rank one formula // see par 4.10 pag 30 const MnAlgebraicSymMatrix& v0 = s0.Error().InvHessian(); MnAlgebraicVector dx = p1.Vec() - s0.Vec(); MnAlgebraicVector dg = g1.Vec() - s0.Gradient().Vec(); double delgam = inner_product(dx, dg); double gvg = similarity(dg, v0); #ifdef DEBUG std::cout << "dx = " << dx << std::endl; std::cout << "dg = " << dg << std::endl; std::cout<<"delgam= "< gvg) { // use rank 1 formula vUpd += gvg*Outer_product(MnAlgebraicVector(dx/delgam - vg/gvg)); } double sum_upd = sum_of_elements(vUpd); vUpd += v0; double dcov = 0.5*(s0.Error().Dcovar() + sum_upd/sum_of_elements(vUpd)); return MinimumError(vUpd, dcov); } /* MinimumError DavidonErrorUpdator::Update(const MinimumState& s0, const MinimumParameters& p1, const FunctionGradient& g1) const { const MnAlgebraicSymMatrix& v0 = s0.Error().InvHessian(); MnAlgebraicVector dx = p1.Vec() - s0.Vec(); MnAlgebraicVector dg = g1.Vec() - s0.Gradient().Vec(); double delgam = inner_product(dx, dg); double gvg = similarity(dg, v0); // std::cout<<"delgam= "<