Mercurial > hg > octave-nkf
changeset 14791:90c131272396
maint: periodic merge of stable to default
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Thu, 21 Jun 2012 14:29:10 -0400 |
parents | acb09716fc94 (current diff) b8041f48b0ff (diff) |
children | 8483286c0a13 |
files | liboctave/Sparse.cc |
diffstat | 1 files changed, 18 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/Sparse.cc +++ b/liboctave/Sparse.cc @@ -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 <class T>