]> gitweb.michael.orlitzky.com - octave.git/blobdiff - optimization/preconditioned_conjugate_gradient_method.m
Fix a comment.
[octave.git] / optimization / preconditioned_conjugate_gradient_method.m
index dec2eeed97418094671d0db34e327e1351820415..f3ff7e2fd56b36e99d6c478cb1a75a18f2bbe170 100644 (file)
@@ -14,8 +14,7 @@ function [x, k] = preconditioned_conjugate_gradient_method(Q, ...
   %   min [phi(x) = (1/2)*<Qx,x> + <b,x>]
   %
   % using the preconditioned conjugate gradient method (14.56 in
-  % Guler). If ``M`` is the identity matrix, we use the slightly
-  % faster implementation in conjugate_gradient_method.m.
+  % Guler).
   %
   % INPUT:
   %
@@ -66,7 +65,8 @@ function [x, k] = preconditioned_conjugate_gradient_method(Q, ...
   %
 
   % We use this in the inner loop.
-  sqrt_n = floor(sqrt(length(x0)));
+  n = length(x0);
+  sqrt_n = floor(sqrt(n));
 
   % Set k=0 first, that way the references to xk,rk,zk,dk which
   % immediately follow correspond (semantically) to x0,r0,z0,d0.