Mercurial > hg > octave-terminal
changeset 10660:4cdc43c095c5
Initialize ARPACK starting vector in svds test code. (bug #29721)
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Wed, 26 May 2010 15:51:02 -0700 |
parents | 8baff2aceabc |
children | 3df114a44da3 |
files | scripts/ChangeLog scripts/sparse/svds.m |
diffstat | 2 files changed, 10 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2010-05-26 Rik <octave@nomad.inbox5.com> + * sparse/svds.m: Initialize ARPACK starting vector in svds test code. + Bug #29721. + 2010-05-25 Ben Abbott <bpabbott@mac.com> * polynomial/spline.m: Ignore NaNs within input vectors.
--- a/scripts/sparse/svds.m +++ b/scripts/sparse/svds.m @@ -208,26 +208,28 @@ %! %%a = sparse([3:n,1:n,1:(n-2)],[1:(n-2),1:n,3:n],[ones(1,n-2),1:n,-ones(1,n-2)]); %! [u,s,v] = svd(full(a)); %! s = diag(s); -%! [dum, idx] = sort(abs(s)); +%! [~, idx] = sort(abs(s)); %! s = s(idx); %! u = u(:,idx); %! v = v(:,idx); %! randn('state',42) +%! opts.v0 = randn (2*n,1); % Initialize eigs ARPACK starting vector +%! % to guarantee reproducible results %!testif HAVE_ARPACK %! [u2,s2,v2,flag] = svds(a,k); %! s2 = diag(s2); %! assert(flag,!1); %! assert(s(end:-1:end-k+1), s2, 1e-10); %!testif HAVE_ARPACK -%! [u2,s2,v2,flag] = svds(a,k,0); +%! [u2,s2,v2,flag] = svds(a,k,0,opts); %! s2 = diag(s2); %! assert(flag,!1); %! assert(s(k:-1:1), s2, 1e-10); %!testif HAVE_ARPACK %! idx = floor(n/2); -%! % Don't put sigma right on a singular value or there are convergence +%! % Don't put sigma right on a singular value or there are convergence issues %! sigma = 0.99*s(idx) + 0.01*s(idx+1); -%! [u2,s2,v2,flag] = svds(a,k,sigma); +%! [u2,s2,v2,flag] = svds(a,k,sigma,opts); %! s2 = diag(s2); %! assert(flag,!1); %! assert(s((idx+floor(k/2)):-1:(idx-floor(k/2))), s2, 1e-10);