diff liboctave/boolNDArray.cc @ 9548:e5f7aee2ab8c

optimize &=, |= operators
author Jaroslav Hajek <highegg@gmail.com>
date Wed, 19 Aug 2009 15:54:31 +0200
parents 8145f2255276
children 3d6a9aea2aea
line wrap: on
line diff
--- a/liboctave/boolNDArray.cc	Wed Aug 19 13:58:50 2009 +0200
+++ b/liboctave/boolNDArray.cc	Wed Aug 19 15:54:31 2009 +0200
@@ -31,6 +31,7 @@
 #include "mx-base.h"
 #include "lo-ieee.h"
 #include "mx-op-defs.h"
+#include "MArray-defs.h"
 
 // unary operations
 
@@ -154,6 +155,50 @@
 SND_BOOL_OPS (bool, boolNDArray, false)
 SND_CMP_OPS (bool, , boolNDArray, )
 
+boolNDArray& 
+mx_el_and_assign (boolNDArray& a, const boolNDArray& b)
+{
+  if (a.is_shared ())
+    return a = mx_el_and (a, b);
+
+  dim_vector a_dims = a.dims ();
+  dim_vector b_dims = b.dims ();
+
+  if (a_dims != b_dims)
+    gripe_nonconformant ("operator &=", a_dims, b_dims);
+  else
+    {
+      octave_idx_type l = a.length ();
+
+      if (l > 0)
+        DO_VV_OP2 (bool, a, &=, b);
+    }
+
+  return a;
+}
+
+boolNDArray& 
+mx_el_or_assign (boolNDArray& a, const boolNDArray& b)
+{
+  if (a.is_shared ())
+    return a = mx_el_and (a, b);
+
+  dim_vector a_dims = a.dims ();
+  dim_vector b_dims = b.dims ();
+
+  if (a_dims != b_dims)
+    gripe_nonconformant ("operator |=", a_dims, b_dims);
+  else
+    {
+      octave_idx_type l = a.length ();
+
+      if (l > 0)
+        DO_VV_OP2 (bool, a, |=, b);
+    }
+
+  return a;
+}
+
 /*
 ;;; Local Variables: ***
 ;;; mode: C++ ***