Mercurial > octave-nkf
comparison scripts/sparse/spy.m @ 5164:57077d0ddc8e
[project @ 2005-02-25 19:55:24 by jwe]
author | jwe |
---|---|
date | Fri, 25 Feb 2005 19:55:28 +0000 |
parents | |
children | 32c569794216 |
comparison
equal
deleted
inserted
replaced
5163:9f3299378193 | 5164:57077d0ddc8e |
---|---|
1 ## Copyright (C) 1998-2004 Andy Adler | |
2 ## | |
3 ## This program is free software; you can redistribute it and/or modify | |
4 ## it under the terms of the GNU General Public License as published by | |
5 ## the Free Software Foundation; either version 2 of the License, or | |
6 ## (at your option) any later version. | |
7 ## | |
8 ## This program is distributed in the hope that it will be useful, | |
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 ## GNU General Public License for more details. | |
12 ## | |
13 ## You should have received a copy of the GNU General Public License | |
14 ## along with this program; if not, write to the Free Software | |
15 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
16 | |
17 ## -*- texinfo -*- | |
18 ## @deftypefn {Function File} {} spy (@var{x}) | |
19 ## Plot the sparsity pattern of the sparse matrix @var{x}. | |
20 ## @end deftypefn | |
21 | |
22 function spy(S) | |
23 if issparse(S) | |
24 [i,j,s,m,n]= spfind(S); | |
25 else | |
26 [i,j,s] = find(S); | |
27 [m,n] = size(S); | |
28 endif | |
29 | |
30 arp = automatic_replot; | |
31 unwind_protect | |
32 automatic_replot = 0; | |
33 | |
34 eval(sprintf('gset nokey')) | |
35 eval(sprintf('gset yrange [0:%d] reverse',m+1)) | |
36 eval(sprintf('gset xrange [0:%d] noreverse',n+1)) | |
37 | |
38 if (length(i)<1000) | |
39 plot(j,i,'*'); | |
40 else | |
41 plot(j,i,'.'); | |
42 endif | |
43 | |
44 #TODO: we should store the reverse state so we don't undo it | |
45 gset yrange [0:1] noreverse | |
46 axis; | |
47 unwind_protect_cleanup | |
48 automatic_replot = arp; | |
49 end_unwind_protect | |
50 endfunction |