Mercurial > hg > octave-nkf
diff src/data.cc @ 9866:b5aa5d9ee6b9
make ismatrix consistent for empty matrices
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 26 Nov 2009 07:53:38 +0100 |
parents | 47c5af1868df |
children | e93c9bfff8b8 |
line wrap: on
line diff
--- 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);