Mercurial > octave-nkf
diff src/ls-mat-ascii.cc @ 8425:2e777f5135a3
support -tabs option for save -ascii
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 25 Dec 2008 12:31:07 +0100 |
parents | 85184151822e |
children | eb63fbe60fab |
line wrap: on
line diff
--- a/src/ls-mat-ascii.cc Wed Dec 24 16:45:11 2008 -0500 +++ b/src/ls-mat-ascii.cc Thu Dec 25 12:31:07 2008 +0100 @@ -329,7 +329,7 @@ bool save_mat_ascii_data (std::ostream& os, const octave_value& val, - int precision) + int precision, bool tabs) { bool success = true; @@ -353,7 +353,21 @@ std::ios::fmtflags oflags = os.flags (static_cast<std::ios::fmtflags> (std::ios::scientific)); - os << m; + if (tabs) + { + for (octave_idx_type i = 0; i < m.rows (); i++) + { + for (octave_idx_type j = 0; j < m.cols (); j++) + { + // Omit leading tabs. + if (j != 0) os << '\t'; + octave_write_double (os, m (i, j)); + } + os << "\n"; + } + } + else + os << m; os.flags (oflags);