Mercurial > hg > octave-lyh
changeset 6456:7f5316cadaa2
[project @ 2007-03-26 16:18:26 by jwe]
author | jwe |
---|---|
date | Mon, 26 Mar 2007 16:18:26 +0000 |
parents | e68b6921b221 |
children | a58b5981ab65 |
files | liboctave/ChangeLog liboctave/chMatrix.cc liboctave/chMatrix.h liboctave/chNDArray.cc liboctave/chNDArray.h src/ChangeLog src/OPERATORS/op-str-str.cc src/file-io.cc test/test_system.m |
diffstat | 9 files changed, 113 insertions(+), 62 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,7 +1,12 @@ -2007-03-24 Luis Ortiz <lortiz@interactivesupercomputing.com> - - * MatrixType.cc (MatrixType::MatrixType(void)): Initialize - sp_bandden to zero for performance reasons as its not used. +2007-03-26 John W. Eaton <jwe@octave.org> + + * chNDArray.cc, chMatrix.cc: Also generate comparison and bool ops. + * chNDArray.h, chMatrix.h: Provide decls. + +2007-03-24 Luis Ortiz <lortiz@interactivesupercomputing.com> + + * MatrixType.cc (MatrixType::MatrixType (void)): Initialize + sp_bandden to zero for performance reasons as it's not used. 2007-03-23 David Bateman <dbateman@free.fr>
--- a/liboctave/chMatrix.cc +++ b/liboctave/chMatrix.cc @@ -204,6 +204,15 @@ MX_ANY_OP (dim); } +MS_CMP_OPS(charMatrix, , char, ) +MS_BOOL_OPS(charMatrix, char, 0) + +SM_CMP_OPS(char, , charMatrix, ) +SM_BOOL_OPS(char, charMatrix, 0) + +MM_CMP_OPS(charMatrix, , charMatrix, ) +MM_BOOL_OPS(charMatrix, charMatrix, 0) + /* ;;; Local Variables: *** ;;; mode: C++ ***
--- a/liboctave/chMatrix.h +++ b/liboctave/chMatrix.h @@ -88,6 +88,17 @@ charMatrix (char *ch, octave_idx_type r, octave_idx_type c) : MArray2<char> (ch, r, c) { } }; +MS_CMP_OP_DECLS (charMatrix, char) +MS_BOOL_OP_DECLS (charMatrix, char) + +SM_CMP_OP_DECLS (char, charMatrix) +SM_BOOL_OP_DECLS (char, charMatrix) + +MM_CMP_OP_DECLS (charMatrix, charMatrix) +MM_BOOL_OP_DECLS (charMatrix, charMatrix) + +MARRAY_FORWARD_DEFS (MArray2, charMatrix, char) + #endif /*
--- a/liboctave/chNDArray.cc +++ b/liboctave/chNDArray.cc @@ -146,6 +146,15 @@ return ::compute_index (ra_idx, dimensions); } +NDS_CMP_OPS(charNDArray, , char, ) +NDS_BOOL_OPS(charNDArray, char, 0) + +SND_CMP_OPS(char, , charNDArray, ) +SND_BOOL_OPS(char, charNDArray, 0) + +NDND_CMP_OPS(charNDArray, , charNDArray, ) +NDND_BOOL_OPS(charNDArray, charNDArray, 0) + /* ;;; Local Variables: *** ;;; mode: C++ ***
--- a/liboctave/chNDArray.h +++ b/liboctave/chNDArray.h @@ -95,6 +95,15 @@ charNDArray (char *d, dim_vector& dv) : MArrayN<char> (d, dv) { } }; +NDS_CMP_OP_DECLS (charNDArray, char) +NDS_BOOL_OP_DECLS (charNDArray, char) + +SND_CMP_OP_DECLS (char, charNDArray) +SND_BOOL_OP_DECLS (char, charNDArray) + +NDND_CMP_OP_DECLS (charNDArray, charNDArray) +NDND_BOOL_OP_DECLS (charNDArray, charNDArray) + MARRAY_FORWARD_DEFS (MArrayN, charNDArray, char) #endif
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +2007-03-26 Juhani Saastamoinen <juhani@cs.joensuu.fi> + + * file-io.cc (do_stream_open) [! HAVE_ZLIB]: + Call fopen with mode, not tmode. + +2007-03-26 John W. Eaton <jwe@octave.org> + + * OPERATORS/op-str-str.cc (DEFCHARNDBINOP): New macro. Use it to + define functions for eq and ne ops. Also define lt, le, ge, and + gt ops. + 2007-03-23 David Bateman <dbateman@free.fr> * DLD-FUNCTIONS/rand.cc: Make more statistical tests optional.
--- a/src/OPERATORS/op-str-str.cc +++ b/src/OPERATORS/op-str-str.cc @@ -50,62 +50,39 @@ // string by string ops. -DEFBINOP (eq, char_matrix_str, char_matrix_str) -{ - CAST_BINOP_ARGS (const octave_char_matrix_str&, - const octave_char_matrix_str&); - - charMatrix cm1 = v1.char_matrix_value (); - charMatrix cm2 = v2.char_matrix_value (); - - if (cm1.rows () == 1 && cm1.columns () == 1) - { - if (cm2.rows () == 1 && cm2.columns () == 1) - return octave_value (cm1 (0, 0) == cm2 (0, 0)); - else - SC_MX_BOOL_OP (char, c, cm1 (0, 0), charMatrix, m, cm2, - c == m (i, j), 0.0); - } - else - { - int cm2_nr = cm2.rows (); - int cm2_nc = cm2.cols (); +#define DEFCHARNDBINOP_FN(name, op, t1, t2, e1, e2, f) \ + BINOPDECL (name, a1, a2) \ + { \ + dim_vector a1_dims = a1.dims (); \ + dim_vector a2_dims = a2.dims (); \ + \ + bool a1_is_scalar = a1_dims.all_ones (); \ + bool a2_is_scalar = a2_dims.all_ones (); \ + \ + CAST_BINOP_ARGS (const octave_ ## t1&, const octave_ ## t2&); \ + \ + if (a1_is_scalar) \ + { \ + if (a2_is_scalar) \ + return octave_value ((v1.e1 ## _value ())(0) op (v2.e2 ## _value ())(0)); \ + else \ + return octave_value (f ((v1.e1 ## _value ())(0), v2.e2 ## _value ())); \ + } \ + else \ + { \ + if (a2_is_scalar) \ + return octave_value (f (v1.e1 ## _value (), (v2.e2 ## _value ())(0))); \ + else \ + return octave_value (f (v1.e1 ## _value (), v2.e2 ## _value ())); \ + } \ + } - if (cm2_nr == 1 && cm2_nc == 1) - MX_SC_BOOL_OP (charMatrix, m, cm1, char, c, cm2 (0, 0), - c == m (i, j), 0.0); - else - MX_MX_BOOL_OP (charMatrix, m1, cm1, charMatrix, m2, cm2, - m1 (i, j) == m2 (i, j), "==", 0.0, 1.0); - } -} - -DEFBINOP (ne, char_matrix_str, char_matrix_str) -{ - CAST_BINOP_ARGS (const octave_char_matrix_str&, - const octave_char_matrix_str&); - - charMatrix cm1 = v1.char_matrix_value (); - charMatrix cm2 = v2.char_matrix_value (); - - if (cm1.rows () == 1 && cm1.columns () == 1) - { - if (cm2.rows () == 1 && cm2.columns () == 1) - return octave_value (cm1 (0, 0) != cm2 (0, 0)); - else - SC_MX_BOOL_OP (char, c, cm1 (0, 0), charMatrix, m, cm2, - c != m (i, j), 1.0); - } - else - { - if (cm2.rows () == 1 && cm2.columns () == 1) - MX_SC_BOOL_OP (charMatrix, m, cm1, char, c, cm2 (0, 0), - c != m (i, j), 1.0); - else - MX_MX_BOOL_OP (charMatrix, m1, cm1, charMatrix, m2, cm2, - m1 (i, j) != m2 (i, j), "!=", 1.0, 0.0); - } -} +DEFCHARNDBINOP_FN (lt, <, char_matrix_str, char_matrix_str, char_array, char_array, mx_el_lt) +DEFCHARNDBINOP_FN (le, <=, char_matrix_str, char_matrix_str, char_array, char_array, mx_el_le) +DEFCHARNDBINOP_FN (eq, ==, char_matrix_str, char_matrix_str, char_array, char_array, mx_el_eq) +DEFCHARNDBINOP_FN (ge, >=, char_matrix_str, char_matrix_str, char_array, char_array, mx_el_ge) +DEFCHARNDBINOP_FN (gt, >, char_matrix_str, char_matrix_str, char_array, char_array, mx_el_gt) +DEFCHARNDBINOP_FN (ne, !=, char_matrix_str, char_matrix_str, char_array, char_array, mx_el_ne) DEFASSIGNOP (assign, char_matrix_str, char_matrix_str) { @@ -126,11 +103,31 @@ INSTALL_UNOP (op_hermitian, octave_char_matrix_str, transpose); INSTALL_UNOP (op_hermitian, octave_char_matrix_sq_str, transpose); + INSTALL_BINOP (op_lt, octave_char_matrix_str, octave_char_matrix_str, lt); + INSTALL_BINOP (op_lt, octave_char_matrix_str, octave_char_matrix_sq_str, lt); + INSTALL_BINOP (op_lt, octave_char_matrix_sq_str, octave_char_matrix_str, lt); + INSTALL_BINOP (op_lt, octave_char_matrix_sq_str, octave_char_matrix_sq_str, lt); + + INSTALL_BINOP (op_le, octave_char_matrix_str, octave_char_matrix_str, le); + INSTALL_BINOP (op_le, octave_char_matrix_str, octave_char_matrix_sq_str, le); + INSTALL_BINOP (op_le, octave_char_matrix_sq_str, octave_char_matrix_str, le); + INSTALL_BINOP (op_le, octave_char_matrix_sq_str, octave_char_matrix_sq_str, le); + INSTALL_BINOP (op_eq, octave_char_matrix_str, octave_char_matrix_str, eq); INSTALL_BINOP (op_eq, octave_char_matrix_str, octave_char_matrix_sq_str, eq); INSTALL_BINOP (op_eq, octave_char_matrix_sq_str, octave_char_matrix_str, eq); INSTALL_BINOP (op_eq, octave_char_matrix_sq_str, octave_char_matrix_sq_str, eq); - + + INSTALL_BINOP (op_ge, octave_char_matrix_str, octave_char_matrix_str, ge); + INSTALL_BINOP (op_ge, octave_char_matrix_str, octave_char_matrix_sq_str, ge); + INSTALL_BINOP (op_ge, octave_char_matrix_sq_str, octave_char_matrix_str, ge); + INSTALL_BINOP (op_ge, octave_char_matrix_sq_str, octave_char_matrix_sq_str, ge); + + INSTALL_BINOP (op_gt, octave_char_matrix_str, octave_char_matrix_str, gt); + INSTALL_BINOP (op_gt, octave_char_matrix_str, octave_char_matrix_sq_str, gt); + INSTALL_BINOP (op_gt, octave_char_matrix_sq_str, octave_char_matrix_str, gt); + INSTALL_BINOP (op_gt, octave_char_matrix_sq_str, octave_char_matrix_sq_str, gt); + INSTALL_BINOP (op_ne, octave_char_matrix_str, octave_char_matrix_str, ne); INSTALL_BINOP (op_ne, octave_char_matrix_str, octave_char_matrix_sq_str, ne); INSTALL_BINOP (op_ne, octave_char_matrix_sq_str, octave_char_matrix_str, ne);
--- a/src/file-io.cc +++ b/src/file-io.cc @@ -443,7 +443,7 @@ else #endif { - FILE *fptr = ::fopen (fname.c_str (), tmode.c_str ()); + FILE *fptr = ::fopen (fname.c_str (), mode.c_str ()); retval = octave_stdiostream::create (fname, fptr, md, flt_fmt);
--- a/test/test_system.m +++ b/test/test_system.m @@ -218,7 +218,7 @@ %% test/octave.test/system/readdir-1.m %!test %! [files, status, msg] = readdir (filesep); -%! assert(iscell (files) && status == 0 && msg == ""); +%! assert(iscell (files) && status == 0 && strcmp (msg, "")); %% test/octave.test/system/readdir-2.m %!error <Invalid call to readdir.*> readdir ();