changeset 27493:cf8784becc8a

maint: merge stable to default.
author Rik <rik@octave.org>
date Mon, 14 Oct 2019 17:23:02 -0700
parents bea2823affa4 (current diff) 616b844e903a (diff)
children 910737d41605
files scripts/set/ismember.m
diffstat 1 files changed, 27 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/set/ismember.m	Mon Oct 14 09:27:10 2019 -0700
+++ b/scripts/set/ismember.m	Mon Oct 14 17:23:02 2019 -0700
@@ -90,7 +90,7 @@
     tf = real_argout{1} & imag_argout{1};
     if (isargout (2))
       s_idx = zeros (size (real_argout{2}));
-      s_idx(tf) = real_argout{2}(tf);
+      s_idx(tf) = min (real_argout{2}(tf), imag_argout{2}(tf));
     endif
     return
   endif
@@ -269,34 +269,38 @@
 %! assert (ismember (abc, {abc}), [false; false; false]);
 
 %!test <*52437>
-%! [tf, s_idx] = ismember ([5 4-3j 3+4j], [5 4-3j 3+4j]);
-%! assert (tf, logical ([1 1 1]))
-%! assert (s_idx, [1 2 3])
+%! [tf, s_idx] = ismember ([5, 4-3j, 3+4j], [5, 4-3j, 3+4j]);
+%! assert (tf, logical ([1, 1, 1]));
+%! assert (s_idx, [1, 2, 3]);
+%!
+%! [tf, s_idx] = ismember ([5, 4-3j, 3+4j], 5);
+%! assert (tf, logical ([1, 0, 0]));
+%! assert (s_idx, [1, 0, 0]);
 %!
-%! [tf, s_idx] = ismember ([5 4-3j 3+4j], 5);
-%! assert (tf, logical ([1 0 0]))
-%! assert (s_idx, [1 0 0])
+%! [tf, s_idx] = ismember ([5, 5, 5], 4-3j);
+%! assert (tf, logical ([0, 0, 0]));
+%! assert (s_idx, [0, 0, 0]);
 %!
-%! [tf, s_idx] = ismember ([5 5 5], 4-3j);
-%! assert (tf, logical ([0 0 0]))
-%! assert (s_idx, [0 0 0])
+%! [tf, s_idx] = ismember ([5, 4-3j, 3+4j; 5i, 6, 6i], [5, 6]);
+%! assert (tf, logical ([1, 0, 0; 0, 1, 0]));
+%! assert (s_idx, [1, 0, 0; 0, 2, 0]);
 %!
-%! [tf, s_idx] = ismember ([5 4-3j 3+4j; 5i 6 6i], [5 6]);
-%! assert (tf, logical ([1 0 0; 0 1 0]))
-%! assert (s_idx, [1 0 0; 0 2 0])
+%! [tf, s_idx] = ismember ([5, 4-3j, 3+4j; 5, 4-3j, 3+4j], [5, 5, 5], "rows");
+%! assert (tf, logical ([0; 0]));
+%! assert (s_idx, [0; 0]);
 %!
-%! [tf, s_idx] = ismember ([5 4-3j 3+4j; 5 4-3j 3+4j], [5 5 5], "rows");
-%! assert (tf, logical ([0; 0]))
-%! assert (s_idx, [0; 0])
+%! [tf, s_idx] = ismember ([5, 5, 5], [5, 4-3j, 3+4j; 5, 5, 5], "rows");
+%! assert (tf, true);
+%! assert (s_idx, 2);
 %!
-%! [tf, s_idx] = ismember ([5 5 5], [5 4-3j 3+4j; 5 5 5], "rows");
-%! assert (tf, true)
-%! assert (s_idx, 2)
+%! tf = ismember ([5, 4-3j, 3+4j], 5);
+%! assert (tf, logical ([1, 0, 0]))
+%! [~, s_idx] = ismember ([5, 4-3j, 3+4j], 5);
+%! assert (s_idx, [1, 0, 0]);
 %!
-%! [tf] = ismember ([5 4-3j 3+4j], 5);
-%! assert (tf, logical ([1 0 0]))
-%! [~, s_idx] = ismember ([5 4-3j 3+4j], 5);
-%! assert (s_idx, [1 0 0])
+%! [tf, s_idx] = ismember (-1-1j, [-1-1j, -1+3j, -1+1j]);
+%! assert (tf, true);
+%! assert (s_idx, 1);
 
 ## Test input validation
 %!error ismember ()