From: Michael Orlitzky Date: Tue, 26 Mar 2013 00:43:19 +0000 (-0400) Subject: Revert "Don't take a redundant parameter in step_length_positive_definite()." X-Git-Url: http://gitweb.michael.orlitzky.com/?p=octave.git;a=commitdiff_plain;h=76a7395151d5d93c696bb350d32efd7e0ff28dd8 Revert "Don't take a redundant parameter in step_length_positive_definite()." This reverts commit 1a6f56b0dd6750649725b2fd07edb3fe0850a886. --- diff --git a/optimization/step_length_positive_definite.m b/optimization/step_length_positive_definite.m index 5d3e8a0..7e15a46 100644 --- a/optimization/step_length_positive_definite.m +++ b/optimization/step_length_positive_definite.m @@ -1,4 +1,4 @@ -function alpha = step_length_positive_definite(g, Q) +function alpha = step_length_positive_definite(g, Q, p) % % Find the minimizer alpha of, % @@ -11,33 +11,34 @@ function alpha = step_length_positive_definite(g, Q) % and ``Q`` is positive-definite. % % The closed-form solution to this problem is given in Nocedal and - % Wright, (3.55). The direction of steepest descent will always be - % the negative gradient direction; this simplified form is given in - % Guler. + % Wright, (3.55). % % INPUT: % % - ``g`` -- The gradient of f at x. % % - ``Q`` -- The positive-definite matrix in the definition of - % ``f`` above. + % ``f`` above. + % + % - ``p`` -- The direction in which ``f`` decreases. The line + % along which we minimize f(x + alpha*p). % % OUTPUT: % - % - ``alpha`` -- The value which decreases ``f`` the most. + % - ``alpha`` -- The value which causes ``f`` to decrease the + % most. % % NOTES: % % All vectors are assumed to be *column* vectors. % - denom = (g' * Q * g); + denom = (p' * Q * p); - % denom is non-negative, since it's a Q-norm. No need to abs() it. - if (denom < eps) + if (abs(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 = eps; + denom = sign(denom)*eps; end - alpha = (g' * g)/denom; + alpha = -(g' * p)/denom; end