Mercurial > hg > octave-avbm
changeset 14433:ec660526ae50 stable
Fix sparse range indexing bug (bug #35570)
* Sparse.cc (Sparse::index): Correctly compute and assign the row and
column index vectors. Also add a test to check for this bug.
author | Marco Caliari <marco.caliari@univr.it> |
---|---|
date | Mon, 05 Mar 2012 09:33:07 -0500 |
parents | 9f7c22795c94 |
children | 3d4bea9accd7 |
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 @@ -1404,7 +1404,11 @@ if (idx.is_range () && idx.increment () == -1) { retval = Sparse<T> (nr, 1, nz); - std::reverse_copy (ridx (), ridx () + nz, retval.ridx ()); + + for (octave_idx_type j = 0; j < nz; j++) + retval.ridx (j) = nr - ridx (nz - j - 1) - 1; + + copy_or_memcpy (2, cidx (), retval.cidx ()); std::reverse_copy (data (), data () + nz, retval.data ()); } else @@ -2726,6 +2730,10 @@ %!test test_sparse_slice([2 2], 22, 3); %!test test_sparse_slice([2 2], 22, 4); +bug #35570: + +%!assert (speye (3,1)(3:-1:1), sparse ([0; 0; 1])) + */ template <class T>