1function test5 (nmat) 2%TEST5 test for BTF 3% Requires UFget 4% Example: 5% test5 6% See also btf, maxtrans, strongcomp, dmperm, UFget, 7% test1, test2, test3, test4, test5. 8 9% Copyright 2007, Timothy A. Davis, http://www.suitesparse.com 10 11index = UFget ; 12 13[ignore f] = sort (index.nnz) ; 14 15% time intensive 16skip_costly = [1514 1297 1876 1301] ; 17f = setdiff (f, skip_costly) ; 18 19if (nargin < 1) 20 nmat = 1000 ; 21end 22nmat = min (nmat, length (f)) ; 23f = f (1:nmat) ; 24 25h = waitbar (0, 'BTF test 5 of 6') ; 26 27try 28 for k = 1:nmat 29 30 i = f(k) ; 31 Prob = UFget (i, index) ; 32 A = Prob.A ; 33 34 waitbar (k/nmat, h) ; 35 36 for tr = [1 -1] 37 38 if (tr == -1) 39 AT = A' ; 40 [m n] = size (A) ; 41 if (m == n) 42 if (nnz (spones (AT) - spones (A)) == 0) 43 fprintf ('skip test with transpose\n') ; 44 continue ; 45 end 46 end 47 A = AT ; 48 end 49 50 tic 51 q1 = maxtrans (A) ; 52 t1 = toc ; 53 r1 = sum (q1 > 0) ; 54 55 tic 56 q2 = maxtrans (A, 10) ; 57 t2 = toc ; 58 r2 = sum (q2 > 0) ; 59 60 fprintf (... 61 '%4d %4d : %10.4f %8d : %10.4f %8d', k, f(k), t1, r1, t2, r2) ; 62 fprintf (' rel sprank %8.4f', r2 / (max (1, r1))) ; 63 if (t2 ~= 0) 64 fprintf (': rel time %8.4f', t1 / t2) ; 65 end 66 fprintf ('\n') ; 67 68 if (r1 ~= r2) 69 disp (Prob) ; 70 fprintf ('^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n') ; 71 end 72 73 end 74 end 75 76catch 77 % out-of-memory is OK, other errors are not 78 disp (lasterr) ; 79 if (isempty (strfind (lasterr, 'Out of memory'))) 80 error (lasterr) ; %#ok 81 else 82 fprintf ('test terminated early, but otherwise OK\n') ; 83 end 84end 85 86close (h) ; 87