diff liboctave/MArray.h @ 5602:dfa2da0563e5

[project @ 2006-01-31 03:43:40 by jwe]
author jwe
date Tue, 31 Jan 2006 03:43:41 +0000
parents 4c8a2e4e0717
children 184ab67c3bc1
line wrap: on
line diff
--- a/liboctave/MArray.h	Sat Jan 21 20:08:33 2006 +0000
+++ b/liboctave/MArray.h	Tue Jan 31 03:43:41 2006 +0000
@@ -63,6 +63,24 @@
       return *this;
     }
 
+  octave_idx_type nnz (void) const
+    {
+      octave_idx_type retval = 0;
+
+      const T *d = this->data ();
+
+      octave_idx_type nel = this->numel ();
+
+      for (octave_idx_type i = 0; i < nel; i++)
+	{
+	  if (d[i] != T ())
+	    retval++;
+	}
+
+      return retval;
+    }
+
+
   // Currently, the OPS functions don't need to be friends, but that
   // may change.