From 602624313348cec0073320c36849e16aba12b4cf Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 25 Mar 2013 20:43:55 -0400 Subject: [PATCH] Refix the non-negativity of denom in step_length_positive_definite(). --- optimization/step_length_positive_definite.m | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/optimization/step_length_positive_definite.m b/optimization/step_length_positive_definite.m index 7e15a46..b9fe48e 100644 --- a/optimization/step_length_positive_definite.m +++ b/optimization/step_length_positive_definite.m @@ -34,11 +34,12 @@ function alpha = step_length_positive_definite(g, Q, p) % denom = (p' * Q * p); - if (abs(denom) < eps) + % denom is non-negative, since it's a Q-norm. No need to abs() it. + if (denom < eps) % Catch divide-by-zeros. If denom is effectively zero, set it to % something tiny instead. This trick is also used in the PCGM. - denom = sign(denom)*eps; + denom = eps; end - alpha = -(g' * p)/denom; + alpha = (g' * g)/denom; end -- 2.44.2