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