changeset 19447:e354372e20f2

allow sparse arrays to be indexed by N-d arrays (bug #43855) * Sparse.cc (Sparse<T>::index (const idx_vector&, bool)): Smash 3rd and higher dimensions of idx vector to allow indexing by N-d arrays.
author John W. Eaton <jwe@octave.org>
date Sun, 21 Dec 2014 01:00:01 -0500
parents 78e424d31596
children a2a79462b7b8
files liboctave/array/Sparse.cc
diffstat 1 files changed, 3 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/array/Sparse.cc	Sat Dec 20 20:07:50 2014 -0800
+++ b/liboctave/array/Sparse.cc	Sun Dec 21 01:00:01 2014 -0500
@@ -1396,12 +1396,9 @@
 
   octave_idx_type nel = numel (); // Can throw.
 
-  const dim_vector idx_dims = idx.orig_dimensions ();
-
-  if (idx_dims.length () > 2)
-    (*current_liboctave_error_handler)
-      ("cannot index sparse matrix with an N-D Array");
-  else if (idx.is_colon ())
+  const dim_vector idx_dims = idx.orig_dimensions ().redim (2);
+
+  if (idx.is_colon ())
     {
       if (nc == 1)
         retval = *this;