# HG changeset patch # User Rik # Date 1386197505 28800 # Node ID 42df174ec2ff7d696f822662085f3d94e5ee9208 # Parent d8d0e9e189f5beea513f6b8dcfab4c25f749b08e setxor.m: Fix bug when "rows" argument given (bug #40808). * setxor.m: When "rows" argument given, use ':' to pick up all columns in find. Add %!test to check behavior. diff -r d8d0e9e189f5 -r 42df174ec2ff scripts/set/setxor.m --- a/scripts/set/setxor.m Wed Dec 04 15:14:18 2013 -0500 +++ b/scripts/set/setxor.m Wed Dec 04 14:51:45 2013 -0800 @@ -61,7 +61,7 @@ na = rows (a); nb = rows (b); [c, i] = sortrows ([a; b]); n = rows (c); - idx = find (all (c(1:n-1) == c(2:n), 2)); + idx = find (all (c(1:n-1, :) == c(2:n, :), 2)); if (! isempty (idx)) c([idx, idx+1],:) = []; i([idx, idx+1],:) = []; @@ -94,9 +94,16 @@ %!assert (setxor ([1,2,3],[2,3,4]),[1,4]) %!assert (setxor ({'a'}, {'a', 'b'}), {'b'}) + %!test %! a = [3, 1, 4, 1, 5]; b = [1, 2, 3, 4]; -%! [y, ia, ib] = setxor (a, b.'); -%! assert (y, [2, 5]); -%! assert (y, sort ([a(ia), b(ib)])); +%! [c, ia, ib] = setxor (a, b.'); +%! assert (c, [2, 5]); +%! assert (c, sort ([a(ia), b(ib)])); +%!test +%! a = [1 2; 4 5; 1 3]; b = [1 1; 1 2; 4 5; 2 10]; +%! [c, ia, ib] = setxor (a, b, "rows"); +%! assert (c, [1 1; 1 3; 2 10]); +%! assert (c, sortrows ([a(ia,:); b(ib,:)])); +