]> gitweb.michael.orlitzky.com - octave.git/blobdiff - optimization/step_length_positive_definite.m
Add classical_iteration() sans comments, refactor jacobi() to use it.
[octave.git] / optimization / step_length_positive_definite.m
index 5d3e8a0b2e92a1d4d4b54606ab9453b5a96be215..255efbac78fd2df4fbc4704fc379e87f624ad77e 100644 (file)
@@ -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,26 +11,28 @@ 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)
@@ -39,5 +41,5 @@ function alpha = step_length_positive_definite(g, Q)
     denom = eps;
   end
 
-  alpha = (g' * g)/denom;
+  alpha = -(g' * p)/denom;
 end