diff liboctave/Sparse.cc @ 10535:3f973f6c841c

improve sparse concatenation operator
author Jaroslav Hajek <highegg@gmail.com>
date Tue, 20 Apr 2010 08:42:03 +0200
parents f094ac9bc93e
children f41c6634d5af
line wrap: on
line diff
--- a/liboctave/Sparse.cc
+++ b/liboctave/Sparse.cc
@@ -2384,6 +2384,9 @@
   octave_idx_type total_nz = 0;
   if (dim == 0 || dim == 1)
     {
+      if (n == 1)
+        return sparse_list[0];
+
       for (octave_idx_type i = 0; i < n; i++)
         {
           if (! dv.concat (sparse_list[i].dims (), dim))
@@ -2392,6 +2395,9 @@
           total_nz += sparse_list[i].nnz ();
         }
     }
+  else
+    (*current_liboctave_error_handler)
+      ("cat: invalid dimension for sparse concatenation");
 
   Sparse<T> retval (dv, total_nz);
 
@@ -2443,8 +2449,7 @@
         break;
       }
     default:
-      (*current_liboctave_error_handler)
-        ("cat: invalid dimension for sparse concatenation");
+      assert (false);
     }
 
   return retval;