Mercurial > octave
changeset 28862:c153b1446e36 stable
colperm.m: Fix for matrices with empty columns (bug #59226).
* scripts/sparse/colperm.m: Change implementation of colperm to work correctly
for matrices with empty columns. Also return the permutation as column
vector, just like the other permutation functions (amd etc.).
author | Marcel Jacobse <mjacobse@uni-bremen.de> |
---|---|
date | Tue, 06 Oct 2020 10:20:44 +0200 |
parents | ba6e10c316d3 |
children | 54b9fcbefd73 |
files | scripts/sparse/colperm.m |
diffstat | 1 files changed, 4 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/sparse/colperm.m Wed Oct 07 09:35:26 2020 +0200 +++ b/scripts/sparse/colperm.m Tue Oct 06 10:20:44 2020 +0200 @@ -40,8 +40,9 @@ print_usage (); endif - [i, j] = find (s); - idx = find (diff ([j; Inf]) != 0); - [~, p] = sort (idx - [0; idx(1:(end-1))]); + [~, p] = sort (sum (s != 0, 1)); endfunction + + +%!assert <*59226> (colperm ([1,0;0,0]), [2, 1])