From: Michael Orlitzky Date: Tue, 26 Mar 2013 00:43:55 +0000 (-0400) Subject: Refix the non-negativity of denom in step_length_positive_definite(). X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=602624313348cec0073320c36849e16aba12b4cf;p=octave.git Refix the non-negativity of denom in step_length_positive_definite(). --- 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