]> gitweb.michael.orlitzky.com - octave.git/commitdiff
Replace step_length_cgm() with a direct call to step_length_positive_definite().
authorMichael Orlitzky <michael@orlitzky.com>
Tue, 26 Mar 2013 00:50:11 +0000 (20:50 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Tue, 26 Mar 2013 00:50:11 +0000 (20:50 -0400)
optimization/step_length_cgm.m [deleted file]
optimization/vanilla_cgm.m

diff --git a/optimization/step_length_cgm.m b/optimization/step_length_cgm.m
deleted file mode 100644 (file)
index 87062f3..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-function alpha = step_length_cgm(r, A, p)
-  %
-  % Compute the step length for the conjugate gradient method (CGM).
-  % The CGM attempts to solve,
-  %
-  %   Ax = b
-  %
-  % or equivalently,
-  %
-  %   min[phi(x) = (1/2)<Ax,x> - <b,x>]
-  %
-  % where ``A`` is positive-definite. In the process, we need to
-  % compute a number of search directions ``p`` and optimal step
-  % lengths ``alpha``; i.e.,
-  %
-  %   x_{k+1} = x_{k} + alpha_{k}*p_{k}
-  %
-  % This function computes alpha_{k} in the formula above.
-  %
-  % INPUT:
-  %
-  %   - ``r`` -- The residual, Ax - b, at the current step.
-  %
-  %   - ``A`` -- The matrix ``A`` in the formulation above.
-  %
-  %   - ``p`` -- The current search direction.
-  %
-  % OUTPUT:
-  %
-  %   - ``alpha`` -- The minimizer of ``f(x) = x + alpha*p`` along ``p`.
-  %
-  % NOTES:
-  %
-  % All vectors are assumed to be *column* vectors.
-  %
-
-  % A simple calculation should convince you that the gradient of
-  % phi(x) above is Ax - b == r.
-  alpha = step_length_positive_definite(r, A, p);
-end
index c4d8f0796bd6721c96bb8c593dfbc3b8fa37d230..b511b484dfaab2ecba7fa6b8702be5080f977ba9 100644 (file)
@@ -45,7 +45,7 @@ function [x, k] = vanilla_cgm(A, b, x0, tolerance, max_iterations)
   pk = -rk;
 
   while (k <= max_iterations && norm(rk, 'inf') > tolerance)
   pk = -rk;
 
   while (k <= max_iterations && norm(rk, 'inf') > tolerance)
-    alpha_k = step_length_cgm(rk, A, pk);
+    alpha_k = step_length_positive_definite(rk, A, pk);
     x_next = xk + alpha_k*pk;
 
     % Avoid accumulated roundoff errors.
     x_next = xk + alpha_k*pk;
 
     % Avoid accumulated roundoff errors.