Mercurial > hg > octave-nkf
view scripts/sparse/nonzeros.m @ 5506:b4cfbb0ec8c4
[project @ 2005-10-23 19:09:32 by dbateman]
author | dbateman |
---|---|
date | Sun, 23 Oct 2005 19:09:33 +0000 |
parents | 57077d0ddc8e |
children | 2c85044aa63f |
line wrap: on
line source
## Copyright (C) 2004 Paul Kienzle ## ## This program is free software and is in the public domain ## -*- texinfo -*- ## @deftypefn {Function File} {} nonzeros (@var{s}) ## Returns a vector of the non-zero values of the sparse matrix @var{s}. ## @end deftypefn function t = nonzeros(s) if issparse(s) [i,j,t] = spfind(s); else [i,j,t] = find(s); endif endfunction %!assert(nonzeros([1,2;3,0]),[1;3;2]) %!assert(nonzeros(sparse([1,2;3,0])),[1;3;2])