# HG changeset patch # User Jaroslav Hajek # Date 1259237859 -3600 # Node ID 47f36dd27203d8d67bb0da48ca48c25621c4c149 # Parent 90bc0cc4518f350d6f32404af98299059d20d3ce randomize initial guess in normest diff -r 90bc0cc4518f -r 47f36dd27203 scripts/ChangeLog --- a/scripts/ChangeLog Thu Nov 26 13:06:59 2009 +0100 +++ b/scripts/ChangeLog Thu Nov 26 13:17:39 2009 +0100 @@ -1,3 +1,7 @@ +2009-11-26 Jaroslav Hajek + + * linear-algebra/normest.m: Randomize initial vector. + 2009-11-26 Jaroslav Hajek * linear-algebra/dot.m: Remove. diff -r 90bc0cc4518f -r 47f36dd27203 scripts/linear-algebra/normest.m --- a/scripts/linear-algebra/normest.m Thu Nov 26 13:06:59 2009 +0100 +++ b/scripts/linear-algebra/normest.m Thu Nov 26 13:17:39 2009 +0100 @@ -42,6 +42,10 @@ e = norm (x); if (e > 0) [m, n] = size (A); + ## Randomize x to avoid bad guesses for important matrices. + ## FIXME: can we do something smarter? + x .*= randn (n, 1); + e = norm (x); x /= e; e0 = 0; while (abs (e - e0) > tol * e)