Mercurial > hg > octave-shane
changeset 14789:62219ea36f05 stable
Assign the sparse column index when deleting contiguous columns (bug #36656)
* Sparse.cc (Sparse<T>::delete_elements): Fix the offset for which the
column index needs to be amended after deleting columns. Add a test.
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Thu, 21 Jun 2012 14:23:33 -0400 |
parents | c50cc3c50890 |
children | b8041f48b0ff |
files | liboctave/Sparse.cc |
diffstat | 1 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/Sparse.cc +++ b/liboctave/Sparse.cc @@ -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 <class T>