Mercurial > hg > octave-nkf
diff src/ov-base-mat.cc @ 4875:e674c7111b88
[project @ 2004-04-22 18:12:31 by jwe]
author | jwe |
---|---|
date | Thu, 22 Apr 2004 18:12:31 +0000 |
parents | 499d2ca46982 |
children | c638c144d4da |
line wrap: on
line diff
--- a/src/ov-base-mat.cc +++ b/src/ov-base-mat.cc @@ -209,20 +209,18 @@ octave_base_matrix<MT>::is_true (void) const { bool retval = false; - - if (matrix.dims () . length () == 2) + dim_vector dv = matrix.dims (); + int nel = dv.numel (); + + if (nel > 0) { - if (rows () > 0 && columns () > 0) - { - boolNDArray m = (matrix.all () . all ()); - - retval = (m.rows () == 1 && m.columns () == 1 && m(0,0)); - } + MT t1 (matrix.reshape (dim_vector (nel, 1))); + + boolNDArray t2 = t1.all (); + + retval = t2(0,0); } - else - (*current_liboctave_error_handler) - ("is_true not yet implemented for N-d Arrays"); - + return retval; }