]> gitweb.michael.orlitzky.com - octave.git/commitdiff
Tiny refactoring in the PCGM.
authorMichael Orlitzky <michael@orlitzky.com>
Mon, 25 Mar 2013 22:48:14 +0000 (18:48 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Mon, 25 Mar 2013 22:48:14 +0000 (18:48 -0400)
optimization/preconditioned_conjugate_gradient_method.m

index dec2eeed97418094671d0db34e327e1351820415..e2f841aefea06ec92e8bb1e8dbe85eb5f2b65747 100644 (file)
@@ -66,7 +66,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.