diff src/ov.cc @ 8346:8302788f09db

fix empty matrix handling in switch statement
author Jaroslav Hajek <highegg@gmail.com>
date Tue, 25 Nov 2008 14:04:55 +0100
parents c777f3ce02d8
children 8b1a2555c4e2
line wrap: on
line diff
--- a/src/ov.cc	Tue Nov 25 14:04:55 2008 +0100
+++ b/src/ov.cc	Tue Nov 25 14:04:55 2008 +0100
@@ -1223,6 +1223,25 @@
   return retval;
 }
 
+bool
+octave_value::is_equal (const octave_value& test) const
+{
+  bool retval = false;
+
+  // If there is no op_eq for these types, we can't compare values.
+
+  if (rows () == test.rows () && columns () == test.columns ())
+    {
+      octave_value tmp = do_binary_op (octave_value::op_eq, *this, test);
+
+      // Empty array also means a match.
+      if (! error_state && tmp.is_defined ())
+	retval = tmp.is_true () || tmp.is_empty ();
+    }
+
+  return retval;
+}
+
 Cell
 octave_value::cell_value (void) const
 {