# HG changeset patch # User Polishchuk Vladimir # Date 1375805025 -10800 # Node ID 8ff3c01eb743307ebd2263aacb7ca9e109650d78 # Parent 1c2f14a7935d8237db1f85fabe4152a3f1bfa32b corect bag in svds.m diff -r 1c2f14a7935d -r 8ff3c01eb743 scripts/sparse/svds.m --- a/scripts/sparse/svds.m Mon Aug 05 15:54:56 2013 -0700 +++ b/scripts/sparse/svds.m Tue Aug 06 19:03:45 2013 +0300 @@ -164,6 +164,10 @@ b_sigma = b_sigma / max_a; endif + if (!ischar (sigma)) + norma = normest (b); + endif + if (b_sigma == 0) ## Find the smallest eigenvalues ## The eigenvalues returns by eigs for sigma=0 are symmetric about 0. @@ -174,6 +178,13 @@ ## computation scales with k we'd like to avoid doubling k for all ## scalar values of sigma. b_k = 2 * k; + ## Find eigenvalues symmetric about tolerance for get positive rather + ## than negative eigenvalues with the same magnitude. + if (opts.tol == 0) + b_sigma = norma * eps() * 3; + else + b_sigma = norma * opts.tol; + endif else b_k = k; # Normal case, find just the k largest eigenvalues endif @@ -188,8 +199,6 @@ if (ischar (sigma)) norma = max (s); - else - norma = normest (A); endif ## We wish to exclude all eigenvalues that are less than zero as these ## are artifacts of the way the matrix passed to eigs is formed. There