# HG changeset patch # User jwe # Date 1107831673 0 # Node ID 3bf4c0cd775d783f4424cdb563e93e48fc5bf337 # Parent 9171ba7831d078720ba5aac1a1476c6b0ec69b05 [project @ 2005-02-08 03:01:13 by jwe] diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2005-02-07 John W. Eaton + + * DLD-FUNCTIONS/find.cc (find_nonzero_elem_idx): Return [] instead + of [](1x0) for scalar arg of zero. + 2005-02-06 John W. Eaton * DLD-FUNCTIONS/gplot.l (tmp_files): Delete. diff --git a/src/DLD-FUNCTIONS/find.cc b/src/DLD-FUNCTIONS/find.cc --- a/src/DLD-FUNCTIONS/find.cc +++ b/src/DLD-FUNCTIONS/find.cc @@ -52,15 +52,20 @@ } // If the original argument was a row vector, force a row vector of - // the overall indices to be returned. + // the overall indices to be returned. But see below for scalar + // case... int result_nr = count; int result_nc = 1; + bool scalar_arg = false; + if (nda.ndims () == 2 && nda.rows () == 1) { result_nr = 1; result_nc = count; + + scalar_arg = (nda.columns () == 1); } Matrix idx (result_nr, result_nc); @@ -105,6 +110,8 @@ } } } + else if (scalar_arg) + val.resize (dim_vector (0, 0)); switch (nargout) {