Mercurial > hg > octave-avbm
changeset 12647:e38fb1910563 stable
Allow sortrows to work on arrays with one row (bug #33197)
* ov-base-scalar.h (octave_base_scalar<T>::sort_rows_idx):
Return single index, not empty index array.
From Marco Caliari <marco.caliari@univr.it>.
* sortrows.m: New test.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 04 May 2011 22:10:24 -0400 |
parents | eaba9d671fb7 |
children | c6378cec77af |
files | scripts/general/sortrows.m src/ov-base-scalar.h |
diffstat | 2 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/general/sortrows.m +++ b/scripts/general/sortrows.m @@ -102,3 +102,14 @@ %! assert (issparse (sx)); %! assert (x, full (sx)); %! assert (idx, sidx); + +%!test +%! m = [1, 0, 0, 4]; +%! c = 1; +%! [x, idx] = sortrows (m, c); +%! [sx, sidx] = sortrows (sparse (m), c); +%! assert (x, m); +%! assert (idx, 1); +%! assert (issparse (sx)); +%! assert (x, full (sx)); +%! assert (idx, sidx);
--- a/src/ov-base-scalar.h +++ b/src/ov-base-scalar.h @@ -109,7 +109,10 @@ { return mode ? mode : ASCENDING; } Array<octave_idx_type> sort_rows_idx (sortmode) const - { return Array<octave_idx_type> (dim_vector (1, 0)); } + { + return Array<octave_idx_type> (dim_vector (1, 1), + static_cast<octave_idx_type> (0)); + } sortmode is_sorted_rows (sortmode mode = UNSORTED) const { return mode ? mode : ASCENDING; }