Mercurial > hg > octave-lyh
changeset 4557:dd92abda6569
[project @ 2003-10-28 15:56:19 by jwe]
author | jwe |
---|---|
date | Tue, 28 Oct 2003 15:56:19 +0000 |
parents | 773a21e4fce8 |
children | 239df9c618ef |
files | liboctave/mx-inlines.cc |
diffstat | 1 files changed, 19 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/mx-inlines.cc +++ b/liboctave/mx-inlines.cc @@ -383,17 +383,27 @@ boolNDArray retval; \ \ dim_vector dv = dims (); \ - \ + /* Check to see if we have a empty matrix: [] */ \ + if (dv.length () == 2 && dv (0) == 0 && dv (1) == 0) \ + { \ + dim_vector dv_temp (1,1); \ + retval.resize (dv_temp,false); \ + return retval; \ + } \ if (dim == -1)/* We need to find first non-singleton dim */ \ { \ - for (int i = 0; i < dv.length (); i++) \ - { \ - if (dv (i) > 1) \ - { \ - dim = i; \ - break; \ - } \ - } \ + /* Be sure to return a scalar if we have a vector */ \ + if (dv.length () == 2 && dv (0) == 1 && dv (1) >= 1) \ + dim = 1; \ + else \ + for (int i = 0; i < dv.length (); i++) \ + { \ + if (dv (i) > 1) \ + { \ + dim = i; \ + break; \ + } \ + } \ if (dim == -1) \ { \ (*current_liboctave_error_handler) \