comparison scripts/sparse/spy.m @ 6446:f82f516c8a00

[project @ 2007-03-23 21:20:21 by jwe]
author jwe
date Fri, 23 Mar 2007 21:20:21 +0000
parents ddfe04062467
children 2c19eaa2c6f7
comparison
equal deleted inserted replaced
6445:407c08a8e5b7 6446:f82f516c8a00
18 ## -*- texinfo -*- 18 ## -*- texinfo -*-
19 ## @deftypefn {Function File} {} spy (@var{x}) 19 ## @deftypefn {Function File} {} spy (@var{x})
20 ## Plot the sparsity pattern of the sparse matrix @var{x}. 20 ## Plot the sparsity pattern of the sparse matrix @var{x}.
21 ## @end deftypefn 21 ## @end deftypefn
22 22
23 function spy(S) 23 function spy (S)
24 if issparse(S) 24
25 [i,j,s,m,n]= spfind(S); 25 if (issparse (S))
26 [i, j, s, m, n] = spfind (S);
26 else 27 else
27 [i,j,s] = find(S); 28 [i, j, s] = find (S);
28 [m,n] = size(S); 29 [m, n] = size (S);
29 endif 30 endif
30 31
31 arp = automatic_replot; 32 if (numel (i) < 1000)
32 unwind_protect 33 plot (j, i, "*");
33 automatic_replot (0); 34 else
35 plot (j, i, ".");
36 endif
34 37
35 eval(sprintf('__gnuplot_set__ nokey')) 38 axis ([0, n+1, 0, m+1]);
36 eval(sprintf('__gnuplot_set__ yrange [0:%d] reverse',m+1))
37 eval(sprintf('__gnuplot_set__ xrange [0:%d] noreverse',n+1))
38 39
39 if (length(i)<1000)
40 plot(j,i,'*');
41 else
42 plot(j,i,'.');
43 endif
44
45 #TODO: we should store the reverse state so we don't undo it
46 __gnuplot_set__ yrange [0:1] noreverse
47 axis;
48 unwind_protect_cleanup
49 automatic_replot (arp);
50 end_unwind_protect
51 endfunction 40 endfunction