Mercurial > octave
changeset 25196:6254e47f2c6c
maint: Merge stable to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 10 Apr 2018 13:37:09 -0400 |
parents | e3034c1956a3 (current diff) 2f0c0c0652d5 (diff) |
children | ff830f8e61ac |
files | |
diffstat | 1 files changed, 11 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/find.cc Tue Apr 10 09:56:43 2018 -0400 +++ b/libinterp/corefcn/find.cc Tue Apr 10 13:37:09 2018 -0400 @@ -439,8 +439,14 @@ // matrix. Try to reuse the possibly cached index vector. // No need to catch index_exception, since arg is bool. - // Out-of-range errors have already set pos, and will be caught later. - retval(0) = arg.index_vector ().unmask (); + // Out-of-range errors have already set pos, and will be + // caught later. + + octave_value result = arg.index_vector ().unmask (); + + dim_vector dv = result.dims (); + + retval(0) = (dv.isvector () ? result : result.reshape (dv.as_column ())); } else { @@ -540,6 +546,9 @@ %!assert (find ([1; 0; 3; 0; 1]), [1; 3; 5]) %!assert (find ([0, 0, 2; 0, 3, 0; -1, 0, 0]), [3; 5; 7]) +%!assert <*53603> (find (ones (1,1,2) > 0), [1;2]) +%!assert <*53603> (find (ones (1,1,1,3) > 0), [1;2;3]) + %!test %! [i, j, v] = find ([0, 0, 2; 0, 3, 0; -1, 0, 0]); %!