Mercurial > hg > octave-terminal
changeset 9866:b5aa5d9ee6b9
make ismatrix consistent for empty matrices
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 26 Nov 2009 07:53:38 +0100 |
parents | 763906db555e |
children | 1c274aa2b4d1 |
files | src/ChangeLog src/data.cc |
diffstat | 2 files changed, 9 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2009-11-26 Jaroslav Hajek <highegg@gmail.com> + + * data.cc (Fismatrix): Return true for empty matrices as well. + 2009-11-25 Jaroslav Hajek <highegg@gmail.com> * DLD-FUNCTIONS/chol.cc (get_chol_l): New helper function.
--- a/src/data.cc +++ b/src/data.cc @@ -3356,10 +3356,7 @@ { octave_value arg = args(0); - if (arg.is_scalar_type () || arg.is_range ()) - retval = true; - else if (arg.is_matrix_type ()) - retval = (arg.rows () >= 1 && arg.columns () >= 1); + retval = arg.is_matrix_type () || arg.is_scalar_type () || arg.is_range (); } else print_usage (); @@ -3369,20 +3366,17 @@ /* +%!assert(ismatrix ([])); %!assert(ismatrix (1)); %!assert(ismatrix ([1, 2, 3])); %!assert(ismatrix ([1, 2; 3, 4])); - -%% Yes, this is right, ismatrix() checks for non-empty matrices. -%!assert(ismatrix ([]), false); - +%!assert(ismatrix (zeros (3, 2, 4))); + +%!assert(ismatrix (single([]))); %!assert(ismatrix (single(1))); %!assert(ismatrix (single([1, 2, 3]))); %!assert(ismatrix (single([1, 2; 3, 4]))); -%% Yes, this is right, ismatrix() checks for non-empty matrices. -%!assert(ismatrix (single([])), false); - %!assert(ismatrix ("t"), false); %!assert(ismatrix ("test"), false); %!assert(ismatrix (["test"; "ing"]), false);