# HG changeset patch
# User Marco Caliari
# Date 1497611150 -7200
# Fri Jun 16 13:05:50 2017 +0200
# Branch stable
# Node ID e5713c9543177b8cbd11536a8563c6112d9199b6
# Parent 49eee76972979fb57111c275fd49a0b5270567cb
Fix possible infinite loop in normest1.m (bug #51241)
* scripts/linear-algebra/normest1.m: fix the computation of available
unparallel columns in S.
diff -r 49eee7697297 -r e5713c954317 scripts/linear-algebra/normest1.m
--- a/scripts/linear-algebra/normest1.m Wed Jun 14 13:22:45 2017 +0200
+++ b/scripts/linear-algebra/normest1.m Fri Jun 16 13:05:50 2017 +0200
@@ -194,15 +194,14 @@ function [est, v, w, k] = normest1 (A, t
if (t > 1)
## at least two columns of S are not parallel
i = 1;
- imax = min (t, 2 ^ (n - 1));
+ imax = min (t, 2 ^ (n - 1) - n);
while (i <= imax)
- ## The maximum number of parallel columns of length n with entries
- ## {-1,1} is 2^(n-1). Therefore, if the number of columns of S is
- ## greater than 2^(n-1), for sure some of them are parallel to some
- ## columns of Sold. Don't even try to change them (i <= 2^(n-1)).
+ ## The maximum number of unparallel columns of length n
+ ## with entries {-1,1} is 2^(n-1). n of them are already
+ ## in Sold.
## Now, check if S(:,i) is parallel to any previous column of S
- p = (any (abs (S(:,i)' * S(:,1:i-1)) == n));
- if (p || (any (abs (S(:,i)' * Sold) == n)))
+ if ((any (abs (S(:,i)' * S(:,1:i-1)) == n)) || ...
+ (any (abs (S(:,i)' * Sold) == n)))
## i-th column of S parallel to a previous or to a
## column of Sold: change it.
S(:,i) = sign (2*rand (n, 1)-1);