File: dg.m

package info (click to toggle)
suitesparse 1%3A5.12.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 176,720 kB
  • sloc: ansic: 1,193,914; cpp: 31,704; makefile: 6,638; fortran: 1,927; java: 1,826; csh: 765; ruby: 725; sh: 529; python: 333; perl: 225; sed: 164; awk: 35
file content (74 lines) | stat: -rw-r--r-- 1,591 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
function dg(A)
%DG order and plot A*A', using CHOLMOD's nested dissection
% used by test27.m
% Example:
%   dg(A)
% See also cholmod_test

% Copyright 2007, Timothy A. Davis, http://www.suitesparse.com

A = GB_spones_mex (A) ;
[p cp cm] = nesdis (A, 'row') ;

% get the corresponding column ordering.  Order the columns
% in increasing order of min(find(A(:,j)))

[m n] = size (A) ;
C = A (p,:) ;
qmin = zeros (1,n) ;
for j = 1:n
    qmin (j) = min (find (C (:,j))) ;		%#ok
end
[ignore q] = sort (qmin) ;

C = C (:,q) ;
clf
subplot (2,3,1) ; treeplot (cp)
drawnow
subplot (2,3,2) ; spy (C)
drawnow
% axis off
subplot (2,3,3) ; spy (C*C')
drawnow
% axis off

ncomp = max(cm) ;
fprintf ('# of components: %d\n', ncomp)

% cs = [cm(p) n+1] ;
% cboundaries = find (diff (cs)) ;

fprintf ('size of root %d out of %d rows\n', length (find (cm == ncomp)), m);

[cnt h pa po R] = symbfact2 (A (p,:), 'row') ;
% rc = full (sum (R)) ;

for k = 1:ncomp
    fprintf ('node %4d : parent %4d size %6d work %g\n', ...
    k, cp (k), length (find (cm == k)), sum (cnt (find (cm == k)).^2) ) ;   %#ok
end

subplot (2,3,4) ; spy (A*A') ;
drawnow

subplot (2,3,5) ; spy (R+R') ;
drawnow

pamd = amd2 (A*A') ;        % use AMD from SuiteSparse, not built-in
[cnt h pa po R] = symbfact2 (A (pamd,:), 'row') ;
subplot (2,3,6) ; spy (R+R') ;
drawnow

% s = bisect (A, 'row') ;
% [ignore pp] = sort (s) ;
% E = A(pp,:) ;
% subplot (2,3,4) ; spy (E*E')
% fprintf ('bisect: %d\n', length (find (s == 2))) ;

% spy (C*C')
% hold on
% for j = cboundaries
%     plot ([1 n], [j j], 'r', [j j], [1 n], 'r') ;
% end