Mercurial > hg > octave-lyh
changeset 4875:e674c7111b88
[project @ 2004-04-22 18:12:31 by jwe]
author | jwe |
---|---|
date | Thu, 22 Apr 2004 18:12:31 +0000 |
parents | c69a6a16932b |
children | 05d464a13f43 |
files | src/ChangeLog src/ov-base-mat.cc src/ov-base-scalar.h |
diffstat | 3 files changed, 20 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,4 +1,10 @@ -2004-04-22 John W. Eaton <jwe@bevo.che.wisc.edu> +2004-04-22 David Bateman <dbateman@free.fr> + + * ov-base-scalar.h (octave_base_scalar<ST>::permute): New function. + + * ov-base-mat.cc (octave_base_matrix<MT>::is_true): Make N-d aware. + +2004-04-22 John W. Eaton <jwe@octave.org> * oct-stream.cc (printf_value_cache::curr_value): Now NDArray. (printf_value_cache::double_value): Extract N-d array, not Matrix.
--- 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; }
--- a/src/ov-base-scalar.h +++ b/src/ov-base-scalar.h @@ -81,6 +81,9 @@ dim_vector dims (void) const { static dim_vector dv (1, 1); return dv; } + octave_value permute (const Array<int>& vec, bool inv = false) const + { return scalar; } + size_t byte_size (void) const { return sizeof (ST); } octave_value all (int = 0) const { return (scalar != 0.0); }