# HG changeset patch # User Jordi GutiƩrrez Hermoso # Date 1340303350 14400 # Node ID 90c13127239641607be75347596af15bc6fb96be # Parent acb09716fc94f7dfb956889b4f41a145428b11d8# Parent b8041f48b0ff690968dcd515170f3eb20af2e359 maint: periodic merge of stable to default diff -r acb09716fc94 -r 90c131272396 liboctave/Sparse.cc --- a/liboctave/Sparse.cc Thu Jun 21 12:15:38 2012 +0200 +++ b/liboctave/Sparse.cc Thu Jun 21 14:29:10 2012 -0400 @@ -1248,7 +1248,8 @@ copy_or_memcpy (nz - ubi, tmp.data () + ubi, xdata () + lbi); copy_or_memcpy (nz - ubi, tmp.ridx () + ubi, xridx () + lbi); copy_or_memcpy (lb, tmp.cidx () + 1, cidx () + 1); - mx_inline_sub (nc - ub, xcidx () + 1, tmp.cidx () + ub + 1, ubi - lbi); + mx_inline_sub (nc - ub, xcidx () + lb + 1, + tmp.cidx () + ub + 1, ubi - lbi); } else *this = index (idx_i, idx_j.complement (nc)); @@ -1583,6 +1584,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 ()) { @@ -2736,6 +2741,18 @@ %!assert (speye (3,1)(3:-1:1), sparse ([0; 0; 1])) +## Test removing columns (bug #36656) + +%!test +%! s = sparse (magic (5)); +%! s(:,2:4) = []; +%! assert (s, sparse (magic (5)(:, [1,5]))); + +%!test +%! s = sparse([], [], [], 1, 1); +%! s(1,:) = []; +%! assert (s, sparse ([], [], [], 0, 1)); + */ template