# HG changeset patch # User Jordi GutiƩrrez Hermoso # Date 1340303013 14400 # Node ID 62219ea36f05c5b8f5c141f7f503970bc6a11cd6 # Parent c50cc3c5089070cd382e190cd5f5ca8df6546b05 Assign the sparse column index when deleting contiguous columns (bug #36656) * Sparse.cc (Sparse::delete_elements): Fix the offset for which the column index needs to be amended after deleting columns. Add a test. diff -r c50cc3c50890 -r 62219ea36f05 liboctave/Sparse.cc --- a/liboctave/Sparse.cc Tue Jun 05 16:21:17 2012 -0700 +++ b/liboctave/Sparse.cc Thu Jun 21 14:23:33 2012 -0400 @@ -1246,7 +1246,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)); @@ -2734,6 +2735,13 @@ %!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]))); + */ template