Mercurial > hg > octave-nkf
changeset 19613:06b23f224f52
fix problem with changeset e354372e20f2 (bug #43855)
* Sparse.cc (Sparse<T>::index (const idx_vector&, bool)): Also smash
dimensions when converting index to array.
* build-sparse-tests.sh: Update indexing test.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 21 Dec 2014 17:38:14 -0500 |
parents | 972abb60c30f |
children | cdb6bc186c42 |
files | liboctave/array/Sparse.cc test/build-sparse-tests.sh |
diffstat | 2 files changed, 6 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/array/Sparse.cc +++ b/liboctave/array/Sparse.cc @@ -1493,9 +1493,12 @@ // If indexing a sparse column vector by a vector, the result is a // sparse column vector, otherwise it inherits the shape of index. // Vector transpose is cheap, so do it right here. + + Array<octave_idx_type> tmp_idx = idx.as_array ().as_matrix (); + const Array<octave_idx_type> idxa = (idx_dims(0) == 1 - ? idx.as_array ().transpose () - : idx.as_array ()); + ? tmp_idx.transpose () + : tmp_idx); octave_idx_type new_nr = idxa.rows (); octave_idx_type new_nc = idxa.cols ();
--- a/test/build-sparse-tests.sh +++ b/test/build-sparse-tests.sh @@ -855,7 +855,7 @@ %!assert (as(idx'), sparse (af(idx'))); %!assert (as(flipud (idx(:))), sparse (af(flipud (idx(:))))) %!assert (as([idx,idx]), sparse (af([idx,idx]))) -%!error (as(reshape ([idx;idx], [1,length(idx),2]))) +%!assert (as(reshape ([idx;idx], [1,length(idx),2])), sparse(af(reshape ([idx;idx], [1,length(idx),2])))) %% Slice tests %!assert (as(ridx,cidx), sparse (af(ridx,cidx)))