From a96c50e3fdf8b5278577522a2c5e75766c8670bb Mon Sep 17 00:00:00 2001 From: Zhepei Wang Date: Thu, 24 Nov 2022 23:58:48 +0800 Subject: [PATCH] fixed a corner case when ||g(x_0)|| is exactly zero --- include/lbfgs.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/lbfgs.hpp b/include/lbfgs.hpp index 40e3445..2ca02ea 100644 --- a/include/lbfgs.hpp +++ b/include/lbfgs.hpp @@ -532,7 +532,7 @@ namespace lbfgs gnorm_inf = g.cwiseAbs().maxCoeff(); xnorm_inf = x.cwiseAbs().maxCoeff(); - if (gnorm_inf / std::max(1.0, xnorm_inf) < param.g_epsilon) + if (gnorm_inf / std::max(1.0, xnorm_inf) <= param.g_epsilon) { /* The initial guess is already a stationary point. */ ret = LBFGS_CONVERGENCE; @@ -554,7 +554,7 @@ namespace lbfgs xp = x; gp = g; - /* If the step bound can be provied dynamically, then apply it. */ + /* If the step bound can be provided dynamically, then apply it. */ step_min = param.min_step; step_max = param.max_step; if (cd.proc_stepbound)