8
% Copyright 2006-2007, Timothy A. Davis.
9
% http://www.cise.ufl.edu/research/sparse
21
m = fix (100 * rand (1)) ;
22
n = fix (100 * rand (1)) ;
24
A = sprandn (m, n, d) ;
38
A = A + 1i * sprand (A) * norm (A,1) / 10 ;
43
% A = A (:, colamd (A)) ;
47
R = chol (A'*A + speye (n)) ;
59
[c,h,parent] = symbfact (A, 'col') ; %#ok
62
[V2,Beta2,p,R2] = cs_qr (sparse(A)) ;
68
C = [A ; sparse(m2-m, n)] ;
73
err1 = norm (R1-R2,1) / norm (R1) ;
76
% [svd(A) svd(R1) svd(full(R2))]
78
s2 = svd (full (R2)) ;
80
err2 = norm (s1 - s2) / s1 (1) ;
86
fprintf ('%10.6f %10.6f cs speedup %8.3f sprank %d vs %d\n', t1, t2, t1/t2, sp, n) ;
91
subplot (2,4,1) ; spy (A) ; title ('A colamd') ;
92
subplot (2,4,4) ; spy (Aorig) ; title ('Aorig') ;
93
subplot (2,4,2) ; spy (C) ; title ('A rperm') ;
94
subplot (2,4,5) ; spy (abs(R2)>0) ; title ('spqr R, no zeros') ;
95
subplot (2,4,6) ; spy (R) ; title ('matlab R') ;
96
subplot (2,4,7) ; spy (R2) ; title ('spqr R') ;
97
subplot (2,4,8) ; spy (V2) ; title ('spqr H') ;
105
fprintf ('added %d rows, sprank %d n %d\n', m2-m, sp, n) ;