Mercurial > hg > octave-lyh
diff liboctave/dim-vector.h @ 9027:9a46ba093db4
generalize dim_vector::numel
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 26 Mar 2009 13:20:05 +0100 |
parents | d865363208d6 |
children | 434ae96dc10f |
line wrap: on
line diff
--- a/liboctave/dim-vector.h +++ b/liboctave/dim-vector.h @@ -310,13 +310,13 @@ // vector would have, NOT the number of dimensions (elements in the // dimension vector). - octave_idx_type numel (void) const + octave_idx_type numel (int n = 0) const { int n_dims = length (); - octave_idx_type retval = n_dims > 0 ? elem (0) : 0; + octave_idx_type retval = 1; - for (int i = 1; i < n_dims; i++) + for (int i = n; i < n_dims; i++) retval *= elem (i); return retval;