comparison scripts/sparse/svds.m @ 12195:d25dfa9ed18b

remove configure checks for ARPACK
author John W. Eaton <jwe@octave.org>
date Fri, 28 Jan 2011 14:05:09 -0500
parents b0084095098e
children 5f203b5bbf98
comparison
equal deleted inserted replaced
12194:470857149e61 12195:d25dfa9ed18b
251 %! v = v(:,idx); 251 %! v = v(:,idx);
252 %! randn('state',42); % Initialize to make normest function reproducible 252 %! randn('state',42); % Initialize to make normest function reproducible
253 %! rand('state',42) 253 %! rand('state',42)
254 %! opts.v0 = rand (2*n,1); % Initialize eigs ARPACK starting vector 254 %! opts.v0 = rand (2*n,1); % Initialize eigs ARPACK starting vector
255 %! % to guarantee reproducible results 255 %! % to guarantee reproducible results
256 %!testif HAVE_ARPACK 256 %!test
257 %! [u2,s2,v2,flag] = svds(A,k); 257 %! [u2,s2,v2,flag] = svds(A,k);
258 %! s2 = diag(s2); 258 %! s2 = diag(s2);
259 %! assert(flag,!1); 259 %! assert(flag,!1);
260 %! assert(s2, s(end:-1:end-k+1), 1e-10); 260 %! assert(s2, s(end:-1:end-k+1), 1e-10);
261 %!testif HAVE_ARPACK 261 %!test
262 %! [u2,s2,v2,flag] = svds(A,k,0,opts); 262 %! [u2,s2,v2,flag] = svds(A,k,0,opts);
263 %! s2 = diag(s2); 263 %! s2 = diag(s2);
264 %! assert(flag,!1); 264 %! assert(flag,!1);
265 %! assert(s2, s(k:-1:1), 1e-10); 265 %! assert(s2, s(k:-1:1), 1e-10);
266 %!testif HAVE_ARPACK 266 %!test
267 %! idx = floor(n/2); 267 %! idx = floor(n/2);
268 %! % Don't put sigma right on a singular value or there are convergence issues 268 %! % Don't put sigma right on a singular value or there are convergence issues
269 %! sigma = 0.99*s(idx) + 0.01*s(idx+1); 269 %! sigma = 0.99*s(idx) + 0.01*s(idx+1);
270 %! [u2,s2,v2,flag] = svds(A,k,sigma,opts); 270 %! [u2,s2,v2,flag] = svds(A,k,sigma,opts);
271 %! s2 = diag(s2); 271 %! s2 = diag(s2);
272 %! assert(flag,!1); 272 %! assert(flag,!1);
273 %! assert(s2, s((idx+floor(k/2)):-1:(idx-floor(k/2))), 1e-10); 273 %! assert(s2, s((idx+floor(k/2)):-1:(idx-floor(k/2))), 1e-10);
274 %!testif HAVE_ARPACK 274 %!test
275 %! [u2,s2,v2,flag] = svds(zeros (10), k); 275 %! [u2,s2,v2,flag] = svds(zeros (10), k);
276 %! assert (isequal(u2, eye (10, k)) && isequal (s2, zeros(k)) && isequal (v2, eye(10, 7))) 276 %! assert (isequal(u2, eye (10, k)) && isequal (s2, zeros(k)) && isequal (v2, eye(10, 7)))