changeset 10106:edbe47bc0f88

make numel query more matlab compatible
author Jaroslav Hajek <highegg@gmail.com>
date Thu, 14 Jan 2010 10:17:37 +0100
parents 018d92ad0730
children fd262afea1d1
files src/ChangeLog src/ov-class.cc
diffstat 2 files changed, 6 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Thu Jan 14 03:10:46 2010 -0500
+++ b/src/ChangeLog	Thu Jan 14 10:17:37 2010 +0100
@@ -1,3 +1,8 @@
+2010-01-14  Jaroslav Hajek  <highegg@gmail.com>
+
+	* ov-class.cc (octave_class::numel (const octave_value_list&)): Don't
+	attempt to query overloaded size.
+
 2010-01-13  John W. Eaton  <jwe@octave.org>
 
 	* ov-fcn.h (octave_function (const std::string&, const std::string&)):
--- a/src/ov-class.cc	Thu Jan 14 03:10:46 2010 -0500
+++ b/src/ov-class.cc	Thu Jan 14 10:17:37 2010 +0100
@@ -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;
 }