Mercurial > hg > octave-lyh
changeset 9875:47f36dd27203
randomize initial guess in normest
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 26 Nov 2009 13:17:39 +0100 |
parents | 90bc0cc4518f |
children | 21d81d06b221 |
files | scripts/ChangeLog scripts/linear-algebra/normest.m |
diffstat | 2 files changed, 8 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2009-11-26 Jaroslav Hajek <highegg@gmail.com> + + * linear-algebra/normest.m: Randomize initial vector. + 2009-11-26 Jaroslav Hajek <highegg@gmail.com> * linear-algebra/dot.m: Remove.
--- a/scripts/linear-algebra/normest.m +++ b/scripts/linear-algebra/normest.m @@ -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)