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 75 76 77 78 79 80 81 82 83 84 85 86 87
|
function test13
%TEST13 test cs_counts, cs_etree
%
% Example:
% test13
% See also: testall
% CXSparse, Copyright (c) 2006-2022, Timothy A. Davis. All Rights Reserved.
% SPDX-License-Identifier: LGPL-2.1+
clear functions
randn ('state',0) ;
rand ('state',0) ;
for trial = 1:100
m = fix (100 * rand (1)) ;
n = fix (100 * rand (1)) ;
d = .1 * rand (1) ;
A = sprandn (n,n,d) ;
C = sprandn (m,n,d) ;
A = A+A' ;
fprintf ('m %4d n %4d nnz(A) %6d nnz(C) %6d\n', m, n, nnz(A), nnz(C)) ;
if (~ispc)
if (rand ( ) > .5)
A = A + 1i * sprand (A) ;
end
end
[p1,po1] = etree (A) ;
[p2,po2] = cs_etree (A) ;
[p3,po3] = cs_etree (A, 'sym') ;
% po2 = cs_post (p2) ;
check_if_same (p1,p2) ;
check_if_same (po1,po2) ;
check_if_same (p1,p3) ;
check_if_same (po1,po3) ;
c1 = symbfact (A) ;
c2 = cs_counts (A) ;
% A-A'
check_if_same (c1,c2) ;
c2 = cs_counts (triu (A)) ;
check_if_same (c1,c2) ;
% pause
p0 = etree (A, 'col') ;
% p1 = etree2 (A, 'col') ; % CHOLMOD
p2 = cs_etree (A, 'col') ;
if (~isempty (A))
check_if_same (p0,p2) ;
end
p0 = etree (C, 'col') ;
% p1 = etree2 (C, 'col') ; % CHOLMOD
p2 = cs_etree (C, 'col') ;
if (~isempty (C))
check_if_same (p0,p2) ;
end
% find etree of A'A, and postorder it
[m n] = size (A) ; %#ok
% full (A)
[cp0 cpo0] = etree (A, 'col') ;
% [cp1 cpo1] = etree2 (A, 'col') ; % CHOLMOD
[cp2 cpo2] = cs_etree (A, 'col') ;
% cpo2 = cs_post (cp2) ;
check_if_same (cp0, cp2) ;
check_if_same (cpo0, cpo2) ;
c0 = symbfact (A, 'col') ;
% c1 = symbfact2 (A, 'col') ; % CHOLMOD
c2 = cs_counts (A, 'col') ;
check_if_same (c0, c2) ;
end
|