# HG changeset patch # User Jaroslav Hajek # Date 1259218418 -3600 # Node ID b5aa5d9ee6b96bc411feb753b66b57d36379a420 # Parent 763906db555e55d4d827fb4385b1bb1db515f3e7 make ismatrix consistent for empty matrices diff -r 763906db555e -r b5aa5d9ee6b9 src/ChangeLog --- a/src/ChangeLog Wed Nov 25 15:10:38 2009 -0500 +++ b/src/ChangeLog Thu Nov 26 07:53:38 2009 +0100 @@ -1,3 +1,7 @@ +2009-11-26 Jaroslav Hajek + + * data.cc (Fismatrix): Return true for empty matrices as well. + 2009-11-25 Jaroslav Hajek * DLD-FUNCTIONS/chol.cc (get_chol_l): New helper function. diff -r 763906db555e -r b5aa5d9ee6b9 src/data.cc --- a/src/data.cc Wed Nov 25 15:10:38 2009 -0500 +++ b/src/data.cc Thu Nov 26 07:53:38 2009 +0100 @@ -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);