Mercurial > hg > octave-lyh
changeset 14790:b8041f48b0ff stable
Return sparse column vectors when the indexing allows it (bug #36656)
* Sparse.cc (Sparse<T>::index): Return a column vector when it's known
to be the desired output. Add a test
author | David Bateman <dbateman@free.fr> |
---|---|
date | Thu, 21 Jun 2012 14:24:33 -0400 |
parents | 62219ea36f05 |
children | 90c131272396 f0552937a8eb |
files | liboctave/Sparse.cc |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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 <class T>