1function test7 2%TEST7 test sparse2 3% Example: 4% test7 5% See also cholmod_test 6 7% Copyright 2007, Timothy A. Davis, http://www.suitesparse.com 8 9fprintf ('=================================================================\n'); 10fprintf ('test7: test sparse2\n') ; 11 12randn ('state', 0) ; 13rand ('state', 0) ; 14 15% Prob = ssget (437) 16Prob = ssget (750) %#ok 17A = Prob.A ; 18[m n] = size (A) ; 19 20tic 21[i j x] = find (A) ; 22t = toc ; 23fprintf ('find time %8.4f\n', t) ; 24 25tic ; 26B = sparse2 (i,j,x,m,n) ; %#ok 27t1 = toc ; 28fprintf ('tot: %8.6f\n', t1) 29 30tic ; 31B = sparse2 (i,j,x,m,n) ; %#ok 32t1 = toc ; 33fprintf ('tot: %8.6f again \n', t1) ; 34 35tic ; 36B1 = sparse2 (i,j,x) ; %#ok 37t1 = toc ; 38fprintf ('tot: %8.6f (i,j,x)\n', t1) ; 39 40nz = length (x) ; 41p = randperm (nz) ; 42 43i2 = i(p) ; 44j2 = j(p) ; 45x2 = x(p) ; %#ok 46 47tic ; 48B = sparse2 (i,j,x,m,n) ; %#ok 49t1 = toc ; 50 51fprintf ('tot: %8.6f (jumbled)\n', t1) ; 52 53ii = [i2 ; i2] ; 54jj = [j2 ; j2] ; 55xx = rand (2*nz,1) ; 56 57tic ; 58D = sparse2 (ii,jj,xx,m,n) ; %#ok 59t1 = toc ; 60 61fprintf ('tot %8.6f (duplicates)\n', t1) ; 62 63fprintf ('test7 passed\n') ; 64