Commit 1af736df52e6bf13198b8aaee3acbae577474cbf

Authored by Jürgen Knödlseder
1 parent 81c50500

Correct gradient computation.

To get the gradient we have to *divide* the gradient factor by the scale factor instead of multiplying it. This has been corrected now.
Showing 1 changed file with 4 additions and 3 deletions
include/GOptimizerPar.hpp
1 1 /***************************************************************************
2 2 * GOptimizerPar.hpp - Optimizer parameter class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2013-2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2013-2015 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -227,12 +227,13 @@ double GOptimizerPar::error(void) const
227 227 * @return Parameter gradient.
228 228 *
229 229 * Returns the parameter gradient. The parameter gradient is computed by
230   - * multiplying the gradient factor by the scale factor.
  230 + * dividing the gradient factor by the scale factor. The method returns
  231 + * zero in case that the scale factor is zero.
231 232 ***************************************************************************/
232 233 inline
233 234 double GOptimizerPar::gradient(void) const
234 235 {
235   - return (m_factor_gradient * m_scale);
  236 + return ((m_scale > 0.0) ? m_factor_gradient / m_scale : 0.0);
236 237 }
237 238  
238 239  
... ...