5164
|
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 |
5307
|
15 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
16 ## 02110-1301 USA |
5164
|
17 |
|
18 ## -*- texinfo -*- |
|
19 ## @deftypefn {Function File} {} spy (@var{x}) |
6607
|
20 ## @deftypefnx {Function File} {} spy (@dots{}, @var{markersize}) |
|
21 ## @deftypefnx {Function File} {} spy (@dots{}, @var{LineSpec}) |
|
22 ## Plot the sparsity pattern of the sparse matrix @var{x}. If the argument |
|
23 ## @var{markersize} is given as an scalar value, it is used to determine the |
|
24 ## point size in the plot. If the string @var{LineSpec} is given it is |
|
25 ## passed to @code{plot} and determines the appearance of the plot. |
|
26 ## @seealso{plot} |
5164
|
27 ## @end deftypefn |
|
28 |
6607
|
29 function spy (S, varargin) |
|
30 |
|
31 markersize = NaN; |
|
32 if (numel (i) < 1000) |
|
33 LineSpec = "*"; |
|
34 else |
|
35 LineSpec = "."; |
|
36 endif |
|
37 for i = 1:length(varargin) |
|
38 if (ischar(varargin{i})) |
|
39 LineSpec = varargin{i}; |
|
40 elseif (isscalar (varargin{i})) |
|
41 markersize = varargin{i}; |
|
42 else |
|
43 error ("spy: expected markersize or linespec"); |
|
44 endif |
|
45 endfor |
6446
|
46 |
|
47 if (issparse (S)) |
|
48 [i, j, s, m, n] = spfind (S); |
5164
|
49 else |
6446
|
50 [i, j, s] = find (S); |
|
51 [m, n] = size (S); |
5164
|
52 endif |
|
53 |
6607
|
54 if (isnan (markersize)) |
|
55 plot (j, i, LineSpec); |
6446
|
56 else |
6607
|
57 plot (j, i, LineSpec, "MarkerSize", markersize); |
6446
|
58 endif |
5164
|
59 |
6674
|
60 axis ([0, n+1, 0, m+1], "ij"); |
5164
|
61 |
|
62 endfunction |