~ubuntu-branches/ubuntu/hardy/suitesparse/hardy

« back to all changes in this revision

Viewing changes to BTF/MATLAB/Test/test4b.m

  • Committer: Bazaar Package Importer
  • Author(s): Rafael Laboissiere, Rafael Laboissiere, Ondrej Certik
  • Date: 2008-02-21 14:46:50 UTC
  • mfrom: (1.1.2 upstream) (5.1.1 hardy)
  • Revision ID: james.westby@ubuntu.com-20080221144650-tgeppgj0t7s759i8
Tags: 3.1.0-3
[ Rafael Laboissiere ]
* Upload to unstable

[ Ondrej Certik ]
* XS-DM-Upload-Allowed: yes field added
* Ondrej Certik added to uploaders

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
%TEST4b test script for BTF
2
 
% Requires UFget
3
 
% Example:
4
 
%   test4
5
 
% See also btf, maxtrans, strongcomp, dmperm, UFget,
6
 
%   test1, test2, test3, test4, test5.
7
 
 
8
 
% Copyright 2007, Timothy A. Davis, University of Florida
9
 
 
10
 
clear ;
11
 
 
12
 
quick2 = [ ...
13
 
 1522 -272  1463  1521   460 1507  -838 1533 -1533 -1456 -1512   734   211 ...
14
 
 -385 -735   394  -397  1109 -744  ...
15
 
 -734 -375 -1200 -1536  -837  519  -519  520  -520   189  -189   454   385 ...
16
 
  387 -387   384  -384   386 -386   388 -388   525  -525   526  -526   735 ...
17
 
 1508  209   210  1243 -1243 1534  -840 1234 -1234   390  -390   392  -392 ...
18
 
 -394 1472  1242 -1242   389 -389   391 -391   393  -393  1215 -1215  1216 ...
19
 
-1216  736  -736   737  -737  455  -455 -224  -839  1426 -1426 -1473   396 ...
20
 
 -396  398  -398   400  -400  402  -402  404  -404 -1531   395  -395   397 ...
21
 
  399 -399   401  -401   403 -403   405 -405  -738  -739  1459 -1459  1111 ...
22
 
 1110  376  -376   284  -284 -740  -742 -741  -743  1293 -1293   452   920 ...
23
 
 -745 -446  1462 -1461   448 -448   283 -283  1502 -1502  1292 -1292  1503 ...
24
 
-1503 1291 -1291   445  -445 -746  -747 1300 -1300   435  -435 -1343 -1345 ...
25
 
-1344 1305 -1305   921 -1513 1307 -1307 1369 -1369  1374 -1374  1377 ...
26
 
-1377  748  -748  -749  1510  922  -922 ] ;
27
 
 
28
 
index = UFget ;
29
 
nmat = length (quick2) ;
30
 
dopause = 0 ;
31
 
 
32
 
for k = 1:nmat
33
 
 
34
 
    i = quick2 (k) ;
35
 
    Prob = UFget (abs (i), index) ;
36
 
    disp (Prob) ;
37
 
    if (i < 0)
38
 
        fprintf ('transposed\n') ;
39
 
        A = Prob.A' ;
40
 
        [m n] = size (A) ;
41
 
        if (m == n)
42
 
            if (nnz (spones (A) - spones (Prob.A)) == 0)
43
 
                fprintf ('skip...\n') ;
44
 
                continue ;
45
 
            end
46
 
        end
47
 
    else
48
 
        A = Prob.A ;
49
 
    end
50
 
 
51
 
    tic
52
 
    [p1,q1,r1,work1] = btf (A) ;
53
 
    t1 = toc ;
54
 
    n1 = length (r1) - 1 ;
55
 
    m1 = nnz (diag (A (p1, abs (q1)))) ;
56
 
 
57
 
    limit = work1/nnz(A) ;
58
 
 
59
 
    fprintf ('full search: %g * nnz(A)\n', limit) ;
60
 
 
61
 
    works = linspace(0,limit,9) ;
62
 
    works (1) = eps ;
63
 
    nw = length (works) ;
64
 
 
65
 
    T2 = zeros (nw, 1) ;
66
 
    N2 = zeros (nw, 1) ;
67
 
    M2 = zeros (nw, 1) ;
68
 
 
69
 
    T2 (end) = t1 ;
70
 
    N2 (end) = n1 ;
71
 
    M2 (end) = m1 ;
72
 
 
73
 
    fprintf ('full time %10.4f   blocks %8d  nnz(diag) %8d\n\n', t1, n1, m1) ;
74
 
 
75
 
    subplot (3,4,4) ;
76
 
    drawbtf (A, p1, abs (q1), r1) ;
77
 
    title (Prob.name, 'Interpreter', 'none') ;
78
 
 
79
 
    for j = 1:nw-1
80
 
 
81
 
        maxwork = works (j) ;
82
 
 
83
 
        tic
84
 
        [p2,q2,r2,work2] = btf (A, maxwork) ;
85
 
        t2 = toc ;
86
 
        n2 = length (r2) - 1 ;
87
 
        m2 = nnz (diag (A (p2, abs (q2)))) ;
88
 
        T2 (j) = t2 ;
89
 
        N2 (j) = n2 ;
90
 
        M2 (j) = m2 ;
91
 
 
92
 
        fprintf ('%9.1f %10.4f   blocks %8d  nnz(diag) %8d\n', ...
93
 
            maxwork, t2, n2, m2) ;
94
 
 
95
 
        subplot (3,4,4+j) ;
96
 
        drawbtf (A, p2, abs (q2), r2) ;
97
 
        title (sprintf ('%g', maxwork)) ;
98
 
 
99
 
        ss = [1:j nw] ;
100
 
 
101
 
        subplot (3,4,1) ;
102
 
        plot (works(ss), T2(ss), 'o-') ;  title ('time vs work') ;
103
 
        axis ([0 limit 0 max(T2)]) ;
104
 
 
105
 
        subplot (3,4,2) ;
106
 
        plot (works(ss), N2(ss), 'o-') ; title ('blocks vs work') ;
107
 
        axis ([0 limit 0 n1]) ;
108
 
 
109
 
        subplot (3,4,3) ;
110
 
        plot (works(ss), M2(ss), 'o-') ; title ('nnz(diag) vs work') ;
111
 
        axis ([0 limit 0 m1]) ;
112
 
        drawnow
113
 
 
114
 
    end
115
 
    fprintf ('full time %10.4f   blocks %8d  nnz(diag) %8d\n', t1, n1, m1) ;
116
 
 
117
 
    if (dopause)
118
 
        input ('hit enter: ') ;
119
 
    end
120
 
 
121
 
end
122