diff src/ov-intx.h @ 4964:269c3d6c0569

[project @ 2004-09-04 01:16:28 by jwe]
author jwe
date Sat, 04 Sep 2004 01:16:28 +0000
parents 573d23f9c9cf
children c0866f89c43d
line wrap: on
line diff
--- a/src/ov-intx.h	Fri Sep 03 15:43:30 2004 +0000
+++ b/src/ov-intx.h	Sat Sep 04 01:16:28 2004 +0000
@@ -118,6 +118,32 @@
   empty_clone (void) const
     { return new OCTAVE_VALUE_INT_SCALAR_T (); }
 
+  octave_value do_index_op (const octave_value_list& idx, int resize_ok)
+  {
+    octave_value retval;
+
+    if (idx.valid_scalar_indices ())
+      retval = scalar;
+    else
+      {
+	// XXX FIXME XXX -- this doesn't solve the problem of
+	//
+	//   a = 1; a([1,1], [1,1], [1,1])
+	//
+	// and similar constructions.  Hmm...
+
+	// XXX FIXME XXX -- using this constructor avoids narrowing the
+	// 1x1 matrix back to a scalar value.  Need a better solution
+	// to this problem.
+
+	octave_value tmp (new OCTAVE_VALUE_INT_MATRIX_T (
+			     OCTAVE_VALUE_INT_NDARRAY_EXTRACTOR_FUNCTION ())); 
+	retval = tmp.do_index_op (idx, resize_ok);
+      }
+
+    return retval;
+  }
+
   OCTAVE_INT_T
   OCTAVE_VALUE_INT_SCALAR_EXTRACTOR_FUNCTION (void) const
     { return scalar; }