Mercurial > hg > octave-lyh
annotate scripts/sparse/spy.m @ 7505:f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
author | David Bateman <dbateman@free.fr> |
---|---|
date | Wed, 20 Feb 2008 15:52:11 -0500 |
parents | f084ba47812b |
children | cadc73247d65 |
rev | line source |
---|---|
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 | |
7125 | 33 if (nargin < 1) |
34 print_usage (); | |
35 endif | |
36 | |
6607 | 37 markersize = NaN; |
38 if (numel (i) < 1000) | |
39 LineSpec = "*"; | |
40 else | |
41 LineSpec = "."; | |
42 endif | |
43 for i = 1:length(varargin) | |
44 if (ischar(varargin{i})) | |
45 LineSpec = varargin{i}; | |
46 elseif (isscalar (varargin{i})) | |
47 markersize = varargin{i}; | |
48 else | |
49 error ("spy: expected markersize or linespec"); | |
50 endif | |
51 endfor | |
6446 | 52 |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7125
diff
changeset
|
53 [i, j, s] = find (S); |
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7125
diff
changeset
|
54 [m, n] = size (S); |
5164 | 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 |