Mercurial > hg > octave-nkf
diff liboctave/so-array.h @ 5602:dfa2da0563e5
[project @ 2006-01-31 03:43:40 by jwe]
author | jwe |
---|---|
date | Tue, 31 Jan 2006 03:43:41 +0000 |
parents | 4c8a2e4e0717 |
children | 143b556ce725 |
line wrap: on
line diff
--- a/liboctave/so-array.h +++ b/liboctave/so-array.h @@ -62,6 +62,23 @@ streamoff_array squeeze (void) const { return ArrayN<std::streamoff>::squeeze (); } + octave_idx_type nnz (void) const + { + octave_idx_type retval = 0; + + const std::streamoff *d = this->data (); + + octave_idx_type nel = this->numel (); + + for (octave_idx_type i = 0; i < nel; i++) + { + if (d[i]) + retval++; + } + + return retval; + } + boolNDArray all (int dim = -1) const; boolNDArray any (int dim = -1) const;