From 1af736df52e6bf13198b8aaee3acbae577474cbf Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Tue, 2 Jun 2015 10:50:39 +0200 Subject: [PATCH] Correct gradient computation. --- include/GOptimizerPar.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/GOptimizerPar.hpp b/include/GOptimizerPar.hpp index e374e6b..30604a3 100644 --- a/include/GOptimizerPar.hpp +++ b/include/GOptimizerPar.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * GOptimizerPar.hpp - Optimizer parameter class * * ----------------------------------------------------------------------- * - * copyright (C) 2013-2014 by Juergen Knoedlseder * + * copyright (C) 2013-2015 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -227,12 +227,13 @@ double GOptimizerPar::error(void) const * @return Parameter gradient. * * Returns the parameter gradient. The parameter gradient is computed by - * multiplying the gradient factor by the scale factor. + * dividing the gradient factor by the scale factor. The method returns + * zero in case that the scale factor is zero. ***************************************************************************/ inline double GOptimizerPar::gradient(void) const { - return (m_factor_gradient * m_scale); + return ((m_scale > 0.0) ? m_factor_gradient / m_scale : 0.0); } -- libgit2 0.21.4