# HG changeset patch # User Jordi GutiƩrrez Hermoso # Date 1325777254 18000 # Node ID 402acc45350e1ea32340491e12d3c5a4f3d5c500 # Parent 71e28fda7be991dfcce79814e721a3dab63d9db8 intersect.m: Properly handle the "rows" case with more than 1 output arg (bug #35247) diff -r 71e28fda7be9 -r 402acc45350e scripts/set/intersect.m --- a/scripts/set/intersect.m Thu Jan 05 00:10:19 2012 -0500 +++ b/scripts/set/intersect.m Thu Jan 05 10:27:34 2012 -0500 @@ -57,6 +57,7 @@ [c, ic] = sortrows (c); ii = find (all (c(1:end-1,:) == c(2:end,:), 2)); c = c(ii,:); + len_a = rows (a); else c = [a(:); b(:)]; [c, ic] = sort (c); ## [a(:);b(:)](ic) == c @@ -66,11 +67,12 @@ ii = find (c(1:end-1) == c(2:end)); endif c = c(ii); + len_a = length (a); endif if (nargout > 1) ia = ja(ic(ii)); ## a(ia) == c - ib = jb(ic(ii+1) - length (a)); ## b(ib) == c + ib = jb(ic(ii+1) - len_a); ## b(ib) == c endif if (nargin == 2 && (size (b, 1) == 1 || size (a, 1) == 1)) @@ -105,3 +107,9 @@ %! b = [1 2 3 4 5 6]; %! c = intersect(a,b); %! assert(c, [1,2]); +%!test +%! a = [1 2 3 4; 5 6 7 8; 9 10 11 12]; +%! [b, ia, ib] = intersect(a, a, "rows"); +%! assert(b, a); +%! assert(ia, [1:3]'); +%! assert(ib, [1:3]');