7016
|
1 ## Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Andy Adler |
|
2 ## |
|
3 ## This file is part of Octave. |
5164
|
4 ## |
7016
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by |
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
|
8 ## your option) any later version. |
5164
|
9 ## |
7016
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License for more details. |
5164
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
7016
|
16 ## along with Octave; see the file COPYING. If not, see |
|
17 ## <http://www.gnu.org/licenses/>. |
5164
|
18 |
|
19 ## -*- texinfo -*- |
|
20 ## @deftypefn {Function File} {} spy (@var{x}) |
6607
|
21 ## @deftypefnx {Function File} {} spy (@dots{}, @var{markersize}) |
|
22 ## @deftypefnx {Function File} {} spy (@dots{}, @var{LineSpec}) |
|
23 ## Plot the sparsity pattern of the sparse matrix @var{x}. If the argument |
|
24 ## @var{markersize} is given as an scalar value, it is used to determine the |
|
25 ## point size in the plot. If the string @var{LineSpec} is given it is |
|
26 ## passed to @code{plot} and determines the appearance of the plot. |
|
27 ## @seealso{plot} |
5164
|
28 ## @end deftypefn |
|
29 |
6607
|
30 function spy (S, varargin) |
|
31 |
|
32 markersize = NaN; |
|
33 if (numel (i) < 1000) |
|
34 LineSpec = "*"; |
|
35 else |
|
36 LineSpec = "."; |
|
37 endif |
|
38 for i = 1:length(varargin) |
|
39 if (ischar(varargin{i})) |
|
40 LineSpec = varargin{i}; |
|
41 elseif (isscalar (varargin{i})) |
|
42 markersize = varargin{i}; |
|
43 else |
|
44 error ("spy: expected markersize or linespec"); |
|
45 endif |
|
46 endfor |
6446
|
47 |
|
48 if (issparse (S)) |
|
49 [i, j, s, m, n] = spfind (S); |
5164
|
50 else |
6446
|
51 [i, j, s] = find (S); |
|
52 [m, n] = size (S); |
5164
|
53 endif |
|
54 |
6607
|
55 if (isnan (markersize)) |
|
56 plot (j, i, LineSpec); |
6446
|
57 else |
6607
|
58 plot (j, i, LineSpec, "MarkerSize", markersize); |
6446
|
59 endif |
5164
|
60 |
6674
|
61 axis ([0, n+1, 0, m+1], "ij"); |
5164
|
62 |
|
63 endfunction |