# HG changeset patch # User Mike Miller # Date 1523861964 25200 # Node ID 316b75b0d886d982eef3557811231cc05dd60a5e # Parent 32323f5e61d264b3a1efc63f6b8251fee7f189bb restore find (false) to be compatible with Matlab again (bug #53655) * find.cc (Ffind): Keep the dimensions of an empty logical result, so that find (false) returns the correct size and shape. Add related BISTs. diff -r 32323f5e61d2 -r 316b75b0d886 libinterp/corefcn/find.cc --- a/libinterp/corefcn/find.cc Sun Apr 15 22:03:13 2018 -0700 +++ b/libinterp/corefcn/find.cc Sun Apr 15 23:59:24 2018 -0700 @@ -446,7 +446,8 @@ dim_vector dv = result.dims (); - retval(0) = (dv.isvector () ? result : result.reshape (dv.as_column ())); + retval(0) = (dv.all_zero () || dv.isvector () + ? result : result.reshape (dv.as_column ())); } else { @@ -585,6 +586,11 @@ %! assert (j, jfull); %! assert (all (v == 1)); +%!assert <*53655> (find (false), zeros (0, 0)) +%!assert <*53655> (find ([false, false]), zeros (1, 0)) +%!assert <*53655> (find ([false; false]), zeros (0, 1)) +%!assert <*53655> (find ([false, false; false, false]), zeros (0, 1)) + %!assert (find ([2 0 1 0 5 0], 1), 1) %!assert (find ([2 0 1 0 5 0], 2, "last"), [3, 5])