comparison scripts/set/unique.m @ 11097:ffb2f1ef2097

make issparse, sparse, and spalloc built-in functions
author John W. Eaton <jwe@octave.org>
date Thu, 14 Oct 2010 11:53:04 -0400
parents 36a7163a5484
children fd0a3ac60b0e
comparison
equal deleted inserted replaced
11096:04c3aacbbc46 11097:ffb2f1ef2097
80 ## 80 ##
81 ## are very slow on sparse matrices. Until they are fixed to be as 81 ## are very slow on sparse matrices. Until they are fixed to be as
82 ## fast as for full matrices, operate on the nonzero elements of the 82 ## fast as for full matrices, operate on the nonzero elements of the
83 ## sparse array as long as we are not operating on rows. 83 ## sparse array as long as we are not operating on rows.
84 84
85 ## FIXME -- unique is called when PKG_ADD files are parsed, but 85 if (issparse (x) && ! optrows && nargout <= 1)
86 ## issparse is not yet available because it is coming from a .oct 86 if (nnz (x) < numel (x))
87 ## file?!? 87 y = unique ([0; (full (nonzeros (x)))], varargin{:});
88 88 else
89 if (exist ("issparse")) 89 ## Corner case where sparse matrix is actually full
90 if (issparse (x) && ! optrows && nargout <= 1) 90 y = unique (full (x), varargin{:});
91 if (nnz (x) < numel (x)) 91 endif
92 y = unique ([0; (full (nonzeros (x)))], varargin{:}); 92 return;
93 else
94 ## Corner case where sparse matrix is actually full
95 y = unique (full (x), varargin{:});
96 endif
97 return;
98 endif
99 endif 93 endif
100 94
101 if (optrows) 95 if (optrows)
102 n = rows (x); 96 n = rows (x);
103 dim = 1; 97 dim = 1;