Mercurial > hg > octave-terminal
changeset 4701:34a740dc31a6
[project @ 2004-01-21 19:55:36 by jwe]
author | jwe |
---|---|
date | Wed, 21 Jan 2004 19:55:37 +0000 |
parents | ca3a1d687bba |
children | 4d2e1623c9a9 |
files | src/Cell.h src/ChangeLog src/OPERATORS/op-streamoff.cc src/ls-mat5.cc src/ov-scalar.cc src/ov-scalar.h |
diffstat | 6 files changed, 87 insertions(+), 87 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Cell.h +++ b/src/Cell.h @@ -90,16 +90,6 @@ Cell& assign (const octave_value_list& idx, const Cell& rhs, const octave_value& fill_val = octave_value ()); - octave_value& operator () (int i) { return elem_internal (i); } - - octave_value operator () (int i) const { return elem_internal (i); } - - octave_value& operator () (int i, int j) - { return ArrayN<octave_value>::operator () (i, j); } - - octave_value operator () (int i, int j) const - { return ArrayN<octave_value>::operator () (i, j); } - // XXX FIXME XXX boolMatrix all (int dim = 0) const { return boolMatrix (); } @@ -110,28 +100,6 @@ bool is_true (void) const { return false; } static octave_value resize_fill_value (void) { return Matrix (); } - -private: - - // XXX FIXME XXX -- we need to do something intelligent if there is - // more than one dimension, but for now this is all we need... - - void maybe_resize (int n) - { - if (n >= rows ()) - resize (dim_vector (n + 1, 1), octave_value ()); - } - - octave_value& elem_internal (int n) - { - maybe_resize (n); - return elem (n); - } - - octave_value elem_internal (int n) const - { - return elem (n); - } }; #endif
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,18 @@ +2004-01-21 John W. Eaton <jwe@bevo.che.wisc.edu> + + * ov-scalar.cc (streamoff_array_value): New function. + * ov-scalar.h: Provide decl. + + * OPERATORS/op-streamoff.cc (STREAMOFF_COMP_OP): New maco. + Use it to define streamoff by matrix, streamoff by scalar, scalar + by streamoff, and matrix by streamoff comparison operators. + (install_streamoff_ops): Install them. + + * Cell.h (Cell::operator ()): Delete (we inherit them from Array<T>). + (maybe_resize, elem_internal): Delete unused functions. + + * ls-mat5.cc (write_mat5_cell_array): Cell& arg is now const. + 2004-01-20 John W. Eaton <jwe@bevo.che.wisc.edu> * variables.cc (is_valid_function): If warn, also print error
--- a/src/OPERATORS/op-streamoff.cc +++ b/src/OPERATORS/op-streamoff.cc @@ -66,62 +66,52 @@ DEFNDBINOP_OP (add_s_so, scalar, streamoff, streamoff, streamoff_array, +) DEFNDBINOP_OP (sub_s_so, scalar, streamoff, streamoff, streamoff_array, +) -DEFBINOP (eq, streamoff, streamoff) -{ - CAST_BINOP_ARGS (const octave_streamoff&, - const octave_streamoff&); - - streamoff_array cm1 = v1.streamoff_array_value (); - streamoff_array cm2 = v2.streamoff_array_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 (std::streamoff, c, cm1 (0, 0), streamoff_array, m, cm2, - c == m (i, j), 0.0); - } - else - { - int cm2_nr = cm2.rows (); - int cm2_nc = cm2.cols (); +#define STREAMOFF_COMP_OP(FN, OP, T1, T2) \ + DEFBINOP (FN, T1, T2) \ + { \ + CAST_BINOP_ARGS (const octave_ ## T1&, octave_ ## T2&); \ + \ + streamoff_array cm1 = v1.streamoff_array_value (); \ + streamoff_array cm2 = v2.streamoff_array_value (); \ + \ + if (! error_state) \ + { \ + if (cm1.rows () == 1 && cm1.columns () == 1) \ + { \ + if (cm2.rows () == 1 && cm2.columns () == 1) \ + return octave_value (cm1(0,0) OP cm2(0,0)); \ + else \ + SC_MX_BOOL_OP (std::streamoff, c, cm1 (0, 0), streamoff_array, \ + m, cm2, c OP m(i,j), 0.0); \ + } \ + else \ + { \ + if (cm2.rows () == 1 && cm2.columns () == 1) \ + MX_SC_BOOL_OP (streamoff_array, m, cm1, std::streamoff, \ + c, cm2(0,0), c OP m(i,j), 0.0); \ + else \ + MX_MX_BOOL_OP (streamoff_array, m1, cm1, streamoff_array, \ + m2, cm2, m1(i,j) OP m2(i,j), #OP, 0.0, 1.0); \ + } \ + } \ + else \ + return octave_value (); \ + } - if (cm2_nr == 1 && cm2_nc == 1) - MX_SC_BOOL_OP (streamoff_array, m, cm1, std::streamoff, c, cm2 (0, 0), - c == m (i, j), 0.0); - else - MX_MX_BOOL_OP (streamoff_array, m1, cm1, streamoff_array, m2, cm2, - m1 (i, j) == m2 (i, j), "==", 0.0, 1.0); - } -} +STREAMOFF_COMP_OP (eq, ==, streamoff, streamoff); +STREAMOFF_COMP_OP (ne, !=, streamoff, streamoff); -DEFBINOP (ne, streamoff, streamoff) -{ - CAST_BINOP_ARGS (const octave_streamoff&, - const octave_streamoff&); - - streamoff_array cm1 = v1.streamoff_array_value (); - streamoff_array cm2 = v2.streamoff_array_value (); +STREAMOFF_COMP_OP (eq_so_m, ==, streamoff, matrix); +STREAMOFF_COMP_OP (ne_so_m, !=, streamoff, matrix); - 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 (std::streamoff, c, cm1 (0, 0), streamoff_array, m, cm2, - c != m (i, j), 1.0); - } - else - { - if (cm2.rows () == 1 && cm2.columns () == 1) - MX_SC_BOOL_OP (streamoff_array, m, cm1, std::streamoff, c, cm2 (0, 0), - c != m (i, j), 1.0); - else - MX_MX_BOOL_OP (streamoff_array, m1, cm1, streamoff_array, m2, cm2, - m1 (i, j) != m2 (i, j), "!=", 1.0, 0.0); - } -} +STREAMOFF_COMP_OP (eq_m_so, ==, matrix, streamoff); +STREAMOFF_COMP_OP (ne_m_so, !=, matrix, streamoff); + +STREAMOFF_COMP_OP (eq_so_s, ==, streamoff, scalar); +STREAMOFF_COMP_OP (ne_so_s, !=, streamoff, scalar); + +STREAMOFF_COMP_OP (eq_s_so, ==, scalar, streamoff); +STREAMOFF_COMP_OP (ne_s_so, !=, scalar, streamoff); DEFASSIGNOP (assign, streamoff, streamoff) { @@ -143,6 +133,18 @@ INSTALL_BINOP (op_eq, octave_streamoff, octave_streamoff, eq); INSTALL_BINOP (op_ne, octave_streamoff, octave_streamoff, ne); + INSTALL_BINOP (op_eq, octave_streamoff, octave_matrix, eq_so_m); + INSTALL_BINOP (op_ne, octave_streamoff, octave_matrix, ne_so_m); + + INSTALL_BINOP (op_eq, octave_matrix, octave_streamoff, eq_m_so); + INSTALL_BINOP (op_ne, octave_matrix, octave_streamoff, ne_m_so); + + INSTALL_BINOP (op_eq, octave_streamoff, octave_scalar, eq_so_s); + INSTALL_BINOP (op_ne, octave_streamoff, octave_scalar, ne_so_s); + + INSTALL_BINOP (op_eq, octave_scalar, octave_streamoff, eq_s_so); + INSTALL_BINOP (op_ne, octave_scalar, octave_streamoff, ne_s_so); + INSTALL_BINOP (op_add, octave_streamoff, octave_streamoff, add); INSTALL_BINOP (op_sub, octave_streamoff, octave_streamoff, sub);
--- a/src/ls-mat5.cc +++ b/src/ls-mat5.cc @@ -705,8 +705,8 @@ // the appropriate tag. static bool -write_mat5_cell_array (std::ostream& os, Cell& cell, bool mark_as_global, - bool save_as_floats) +write_mat5_cell_array (std::ostream& os, const Cell& cell, + bool mark_as_global, bool save_as_floats) { int nel = cell.nelem ();
--- a/src/ov-scalar.cc +++ b/src/ov-scalar.cc @@ -92,6 +92,19 @@ return retval; } +streamoff_array +octave_scalar::streamoff_array_value (void) const +{ + streamoff_array retval; + + std::streamoff soff = streamoff_value (); + + if (! error_state) + retval = streamoff_array (dim_vector (1, 1), soff); + + return retval; +} + octave_value octave_scalar::convert_to_str_internal (bool, bool) const {