Mercurial > hg > octave-lyh
diff src/ov-class.cc @ 10106:edbe47bc0f88
make numel query more matlab compatible
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 14 Jan 2010 10:17:37 +0100 |
parents | 2cd940306a06 |
children | cd96d29c5efa |
line wrap: on
line diff
--- a/src/ov-class.cc +++ b/src/ov-class.cc @@ -346,40 +346,7 @@ error ("@%s/numel: invalid return value", cn.c_str ()); } else - { - // If method is not found, calculate using size (). - const Matrix mdv = size (); - octave_idx_type nmdv = mdv.numel (); - dim_vector dv; dv.resize (std::max (nmdv, 2)); - for (octave_idx_type i = 0; i < nmdv && !error_state; i++) - { - if (mdv(i) == xround (mdv(i)) && xfinite (mdv(i)) && mdv(i) >= 0) - dv(i) = mdv(i); - else - error ("@%s/numel: expected nonnegative integers from @%s/size", - cn.c_str (), cn.c_str ()); - } - - if (! error_state) - { - octave_idx_type len = idx.length (); - if (len == 0) - retval = dv.numel (); - else - { - dv = dv.redim (len); - retval = 1; - for (octave_idx_type i = 0; i < len; i++) - { - if (idx(i).is_magic_colon ()) - retval *= dv(i); - else - retval *= idx(i).numel (); - } - } - } - - } + retval = octave_base_value::numel (idx); return retval; }