# HG changeset patch # User David Bateman # Date 1340303073 14400 # Node ID b8041f48b0ff690968dcd515170f3eb20af2e359 # Parent 62219ea36f05c5b8f5c141f7f503970bc6a11cd6 Return sparse column vectors when the indexing allows it (bug #36656) * Sparse.cc (Sparse::index): Return a column vector when it's known to be the desired output. Add a test diff --git a/liboctave/Sparse.cc b/liboctave/Sparse.cc --- a/liboctave/Sparse.cc +++ b/liboctave/Sparse.cc @@ -1582,6 +1582,10 @@ { // It's actually vector indexing. The 1D index is specialized for that. retval = index (idx_i); + + // If nr == 1 then the vector indexing will return a column vector!! + if (nr == 1) + retval.transpose(); } else if (idx_i.is_scalar ()) { @@ -2742,6 +2746,11 @@ %! s(:,2:4) = []; %! assert (s, sparse (magic (5)(:, [1,5]))); +%!test +%! s = sparse([], [], [], 1, 1); +%! s(1,:) = []; +%! assert (s, sparse ([], [], [], 0, 1)); + */ template