Mercurial > hg > octave-nkf
diff liboctave/dim-vector.h @ 4635:f2cd320cbf6e
[project @ 2003-11-20 01:48:23 by jwe]
author | jwe |
---|---|
date | Thu, 20 Nov 2003 01:48:23 +0000 |
parents | fc30061d01da |
children | c8829691db47 |
line wrap: on
line diff
--- a/liboctave/dim-vector.h +++ b/liboctave/dim-vector.h @@ -254,6 +254,18 @@ return retval; } + int + num_ones (void) const + { + int retval = 0; + + for (int i = 0; i < length (); i++) + if (elem (i) == 1) + retval++; + + return retval; + } + // This is the number of elements that a matrix with this dimension // vector would have, NOT the number of dimensions (elements in the // dimension vector).