1function test4 (nmat) 2%TEST4 test for BTF 3% Requires UFget 4% Example: 5% test4 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 ; 12f = find (index.nrows == index.ncols) ; 13[ignore i] = sort (index.nnz (f)) ; 14f = f (i) ; 15 16% time intensive 17skip_costly = [1514 1297 1876 1301] ; 18f = setdiff (f, skip_costly) ; 19 20if (nargin < 1) 21 nmat = 1000 ; 22end 23nmat = min (nmat, length (f)) ; 24f = f (1:nmat) ; 25 26h = waitbar (0, 'BTF test 4 of 6') ; 27 28try 29 for k = 1:nmat 30 31 Prob = UFget (f (k), 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 transpose\n') ; 44 continue ; 45 end 46 end 47 A = AT ; 48 end 49 50 tic 51 [p1,q1,r1,work1] = btf (A) ; 52 t1 = toc ; 53 n1 = length (r1) - 1 ; 54 55 tic 56 [p2,q2,r2,work2] = btf (A, 10) ; 57 t2 = toc ; 58 n2 = length (r2) - 1 ; 59 60 fprintf (... 61 '%4d %4d : %10.4f %8d %8g : %10.4f %8d %8g :', ... 62 k, f(k), t1, n1, work1, t2, n2, work2) ; 63 if (t2 ~= 0) 64 fprintf (' rel %8.4f %8.4f' , t1 / t2, n2 / (max (1, n1))) ; 65 end 66 fprintf ('\n') ; 67 68 if (n1 ~= n2 | work1 ~= work2) %#ok 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