Mercurial > hg > octave-nkf
comparison 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 |
comparison
equal
deleted
inserted
replaced
9865:763906db555e | 9866:b5aa5d9ee6b9 |
---|---|
3354 | 3354 |
3355 if (args.length () == 1) | 3355 if (args.length () == 1) |
3356 { | 3356 { |
3357 octave_value arg = args(0); | 3357 octave_value arg = args(0); |
3358 | 3358 |
3359 if (arg.is_scalar_type () || arg.is_range ()) | 3359 retval = arg.is_matrix_type () || arg.is_scalar_type () || arg.is_range (); |
3360 retval = true; | |
3361 else if (arg.is_matrix_type ()) | |
3362 retval = (arg.rows () >= 1 && arg.columns () >= 1); | |
3363 } | 3360 } |
3364 else | 3361 else |
3365 print_usage (); | 3362 print_usage (); |
3366 | 3363 |
3367 return retval; | 3364 return retval; |
3368 } | 3365 } |
3369 | 3366 |
3370 /* | 3367 /* |
3371 | 3368 |
3369 %!assert(ismatrix ([])); | |
3372 %!assert(ismatrix (1)); | 3370 %!assert(ismatrix (1)); |
3373 %!assert(ismatrix ([1, 2, 3])); | 3371 %!assert(ismatrix ([1, 2, 3])); |
3374 %!assert(ismatrix ([1, 2; 3, 4])); | 3372 %!assert(ismatrix ([1, 2; 3, 4])); |
3375 | 3373 %!assert(ismatrix (zeros (3, 2, 4))); |
3376 %% Yes, this is right, ismatrix() checks for non-empty matrices. | 3374 |
3377 %!assert(ismatrix ([]), false); | 3375 %!assert(ismatrix (single([]))); |
3378 | |
3379 %!assert(ismatrix (single(1))); | 3376 %!assert(ismatrix (single(1))); |
3380 %!assert(ismatrix (single([1, 2, 3]))); | 3377 %!assert(ismatrix (single([1, 2, 3]))); |
3381 %!assert(ismatrix (single([1, 2; 3, 4]))); | 3378 %!assert(ismatrix (single([1, 2; 3, 4]))); |
3382 | |
3383 %% Yes, this is right, ismatrix() checks for non-empty matrices. | |
3384 %!assert(ismatrix (single([])), false); | |
3385 | 3379 |
3386 %!assert(ismatrix ("t"), false); | 3380 %!assert(ismatrix ("t"), false); |
3387 %!assert(ismatrix ("test"), false); | 3381 %!assert(ismatrix ("test"), false); |
3388 %!assert(ismatrix (["test"; "ing"]), false); | 3382 %!assert(ismatrix (["test"; "ing"]), false); |
3389 | 3383 |