diff liboctave/dim-vector.h @ 4567:fc30061d01da

[project @ 2003-10-29 20:11:15 by jwe]
author jwe
date Wed, 29 Oct 2003 20:11:16 +0000
parents 1db951a4fcd5
children f2cd320cbf6e
line wrap: on
line diff
--- a/liboctave/dim-vector.h	Wed Oct 29 15:06:29 2003 +0000
+++ b/liboctave/dim-vector.h	Wed Oct 29 20:11:16 2003 +0000
@@ -253,6 +253,22 @@
 
     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).
+
+  int numel (void) const
+  {
+    int n_dims = length ();
+
+    int retval = n_dims > 0 ? elem (0) : 0;
+
+    for (int i = 1; i < n_dims; i++)
+      retval *= elem (i);
+
+    return retval;
+  }
 };
 
 static inline bool