Mercurial > hg > octave-shane
changeset 9019:12ca81f1fa99
compatibility fix for find called for empty arguments
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 25 Mar 2009 19:02:15 -0400 |
parents | 9057df9bb8a1 |
children | 728e7943752d 97aa01a85ea4 |
files | src/ChangeLog src/DLD-FUNCTIONS/find.cc |
diffstat | 2 files changed, 17 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,8 @@ 2009-03-25 John W. Eaton <jwe@octave.org> + * DLD-FUNCTIONS/find.cc (find_nonzero_elem_idx): Also return + [](0x0) if the array has 0 rows and it is not a column vector. + * oct-stream.cc (octave_stream::write (const Array<T>&, octave_idx_type, oct_data_conv::data_type, octave_idx_type, oct_mach_info::float_format)): Seek to skip if still inside bounds
--- a/src/DLD-FUNCTIONS/find.cc +++ b/src/DLD-FUNCTIONS/find.cc @@ -89,14 +89,23 @@ octave_idx_type result_nr = count; octave_idx_type result_nc = 1; + bool column_vector_arg = false; bool scalar_arg = false; - if (nda.ndims () == 2 && nda.rows () == 1) + if (nda.ndims () == 2) { - result_nr = 1; - result_nc = count; + octave_idx_type nr = nda.rows (); + octave_idx_type nc = nda.columns (); - scalar_arg = (nda.columns () == 1); + if (nr == 1) + { + result_nr = 1; + result_nc = count; + + scalar_arg = (nc == 1); + } + else if (nc == 1) + column_vector_arg = true; } Matrix idx (result_nr, result_nc); @@ -141,7 +150,7 @@ i++; } } - else if (scalar_arg) + else if (scalar_arg || (nda.rows () == 0 && ! column_vector_arg)) { idx.resize (0, 0);