Mercurial > hg > octave-lyh
diff src/ov-cell.cc @ 4513:508238e65af7
[project @ 2003-09-19 21:40:57 by jwe]
author | jwe |
---|---|
date | Fri, 19 Sep 2003 21:41:21 +0000 |
parents | d7d9ca19960a |
children | 8e1c04e506ce |
line wrap: on
line diff
--- a/src/ov-cell.cc +++ b/src/ov-cell.cc @@ -327,47 +327,66 @@ void octave_cell::print_raw (std::ostream& os, bool) const { - int nr = rows (); - int nc = columns (); + int ndims = matrix.ndims (); + + if (ndims == 2) + { + int nr = rows (); + int nc = columns (); + + if (nr > 0 && nc > 0) + { + indent (os); + os << "{"; + newline (os); + + increment_indent_level (); + + for (int j = 0; j < nc; j++) + { + for (int i = 0; i < nr; i++) + { + OCTAVE_QUIT; + + OSSTREAM buf; + buf << "[" << i+1 << "," << j+1 << "]" << OSSTREAM_ENDS; - if (nr > 0 && nc > 0) + octave_value val = matrix(i,j); + + val.print_with_name (os, OSSTREAM_STR (buf)); + + OSSTREAM_FREEZE (buf); + } + } + + decrement_indent_level (); + + indent (os); + os << "}"; + newline (os); + } + else + { + os << "{}"; + if (nr > 0 || nc > 0) + os << "(" << nr << "x" << nc << ")"; + os << "\n"; + } + } + else { indent (os); os << "{"; - newline (os); - - increment_indent_level (); - - for (int j = 0; j < nc; j++) + dim_vector dv = matrix.dims (); + for (int i = 0; i < ndims; i++) { - for (int i = 0; i < nr; i++) - { - OCTAVE_QUIT; - - OSSTREAM buf; - buf << "[" << i+1 << "," << j+1 << "]" << OSSTREAM_ENDS; - - octave_value val = matrix(i,j); - - val.print_with_name (os, OSSTREAM_STR (buf)); - - OSSTREAM_FREEZE (buf); - } + if (i > 0) + os << "x"; + os << dv(i); } - - decrement_indent_level (); - - indent (os); - os << "}"; + os << " Cell Array}"; newline (os); } - else - { - os << "{}"; - if (nr > 0 || nc > 0) - os << "(" << nr << "x" << nc << ")"; - os << "\n"; - } } bool