2
%SSTEST exhaustive performance test for SSMULT.
7
% See also ssmult, ssmultsym, ssmult_unsorted, ssmult_install, sstest2, mtimes.
9
% Copyright 2007, Timothy A. Davis, University of Florida.
11
N = [500:50:1000 1100:100:3000 3200:200:5000 ] ;
15
% warmup for more accurate timings
22
error ('test failure') ;
27
'C=A*B blue, C=B*A red, both real', ...
28
'A real, B complex', 'A complex, B real', 'both complex' } ;
30
xlabels = { '(A random, B diagonal)', '(A random, B permutation)', ...
31
'(A random, B tridiagonal)' } ;
33
fprintf ('\nIn the next plots, speedup is the time for MATLAB C=A*B divided\n');
34
fprintf ('by the time for C=ssmult(A,B). The X-axis is n, the dimension\n') ;
35
fprintf ('of the square matrices A and B. A is a sparse random matrix with\n');
36
fprintf ('1%% nonzero values. B is diagonal in the first row of plots,\n') ;
37
fprintf ('a permutation in the 2nd row, and tridiagonal in the third.\n') ;
38
fprintf ('C=A*B is in blue, C=B*A is in red. A and B are both real in the\n') ;
39
fprintf ('first column of plots, B is complex in the 2nd, A in the 3rd, and\n');
40
fprintf ('both are complex in the 4th column of plots. You will want to\n') ;
41
fprintf ('maximize the figure; otherwise the text is too hard to read.\n') ;
49
fprintf ('Testing C=A*B and C=B*A %s\n', xlabels {fig}) ;
51
T = zeros (length(N),4,4) ;
58
A = sprand (n,n,0.01) ;
61
B = spdiags (rand (n,1), 0, n, n) ;
64
B = spdiags (rand (n,1), 0, n, n) ;
65
B = B (:,randperm(n)) ;
68
B = spdiags (rand (n,3), -1:1, n, n) ;
75
A = A + 1i*sprand (A) ;
79
B = B + 1i*sprand (B) ;
82
A = A + 1i*sprand (A) ;
83
B = B + 1i*sprand (B) ;
101
trials = trials + 1 ;
108
error ('test failure') ;
118
trials = trials + 1 ;
128
trials = trials + 1 ;
135
error ('test failure') ;
144
subplot (3,4,kind + 4*(fig-1)) ;
145
plot (N(1:k), T (1:k,kind,1) ./ T (1:k,kind,2), 'o', ...
146
N(1:k), T (1:k,kind,3) ./ T (1:k,kind,4), 'rx', ...
147
[N(1) n], [1 1], 'k') ;
148
xlabel (['n ' xlabels{fig}]) ;
151
title (titles {kind}) ;
157
% probably because we ran out of memory ...