Classes | |
class | arma_ostream_state |
class | arma_ostream |
Functions | |
arma_ostream_state::arma_ostream_state (const std::ostream &o) | |
void | arma_ostream_state::restore (std::ostream &o) const |
template<typename eT > | |
static u32 | arma_ostream::modify_stream (std::ostream &o, const eT *data, const u32 n_elem) |
template<typename T > | |
static u32 | arma_ostream::modify_stream (std::ostream &o, const std::complex< T > *data, const u32 n_elem) |
"better than nothing" settings for complex numbers | |
template<typename eT > | |
static arma_inline void | arma_ostream::print_elem (std::ostream &o, const eT &x) |
Print an element to the specified stream. | |
template<typename T > | |
static arma_inline void | arma_ostream::print_elem (std::ostream &o, const std::complex< T > &x) |
Print a complex element to the specified stream EXPERIMENTAL ! | |
template<typename eT > | |
static void | arma_ostream::print (std::ostream &o, const Mat< eT > &m, const bool modify) |
Print a matrix to the specified stream. | |
template<typename eT > | |
static void | arma_ostream::print (std::ostream &o, const Cube< eT > &m, const bool modify) |
Print a cube to the specified stream. | |
template<typename oT > | |
static void | arma_ostream::print (std::ostream &o, const field< oT > &m) |
Print a field to the specified stream Assumes type oT can be printed, i.e. oT has std::ostream& operator<< (std::ostream&, const oT&). | |
template<typename oT > | |
static void | arma_ostream::print (std::ostream &o, const subview_field< oT > &m) |
Print a subfield to the specified stream Assumes type oT can be printed, i.e. oT has std::ostream& operator<< (std::ostream&, const oT&). |
arma_ostream_state::arma_ostream_state | ( | const std::ostream & | o | ) | [inline, inherited] |
Definition at line 22 of file arma_ostream_meat.hpp.
00023 : orig_flags (o.flags()) 00024 , orig_precision(o.precision()) 00025 , orig_width (o.width()) 00026 , orig_fill (o.fill()) 00027 { 00028 }
void arma_ostream_state::restore | ( | std::ostream & | o | ) | const [inline, inherited] |
Definition at line 34 of file arma_ostream_meat.hpp.
References arma_ostream_state::orig_fill, arma_ostream_state::orig_flags, arma_ostream_state::orig_precision, and arma_ostream_state::orig_width.
Referenced by print().
00035 { 00036 o.flags (orig_flags); 00037 o.precision(orig_precision); 00038 o.width (orig_width); 00039 o.fill (orig_fill); 00040 }
u32 arma_ostream::modify_stream | ( | std::ostream & | o, | |
const eT * | data, | |||
const u32 | n_elem | |||
) | [inline, static, inherited] |
Definition at line 52 of file arma_ostream_meat.hpp.
Referenced by operator<<(), and print().
00053 { 00054 o.unsetf(ios::showbase); 00055 o.unsetf(ios::uppercase); 00056 o.fill(' '); 00057 00058 u32 cell_width; 00059 00060 bool use_layout_B = false; 00061 bool use_layout_C = false; 00062 00063 for(u32 i=0; i<n_elem; ++i) 00064 { 00065 const eT val = data[i]; 00066 00067 if( 00068 val >= eT(+100) || 00069 ( (is_signed<eT>::value == true) && (val <= eT(-100)) ) || 00070 ( (is_non_integral<eT>::value == true) && (val > eT(0)) && (val <= eT(+1e-4)) ) || 00071 ( (is_non_integral<eT>::value == true) && (is_signed<eT>::value == true) && (val < eT(0)) && (val >= eT(-1e-4)) ) 00072 ) 00073 { 00074 use_layout_C = true; 00075 break; 00076 } 00077 00078 if( 00079 (val >= eT(+10)) || ( (is_signed<eT>::value == true) && (val <= eT(-10)) ) 00080 ) 00081 { 00082 use_layout_B = true; 00083 } 00084 } 00085 00086 if(use_layout_C == true) 00087 { 00088 o.setf(ios::scientific); 00089 o.unsetf(ios::fixed); 00090 o.precision(4); 00091 cell_width = 13; 00092 } 00093 else 00094 if(use_layout_B == true) 00095 { 00096 o.unsetf(ios::scientific); 00097 o.setf(ios::fixed); 00098 o.precision(4); 00099 cell_width = 10; 00100 } 00101 else 00102 { 00103 o.unsetf(ios::scientific); 00104 o.setf(ios::fixed); 00105 o.precision(4); 00106 cell_width = 9; 00107 } 00108 00109 return cell_width; 00110 }
u32 arma_ostream::modify_stream | ( | std::ostream & | o, | |
const std::complex< T > * | data, | |||
const u32 | n_elem | |||
) | [inline, static, inherited] |
"better than nothing" settings for complex numbers
Definition at line 118 of file arma_ostream_meat.hpp.
00119 { 00120 o.unsetf(ios::showbase); 00121 o.unsetf(ios::uppercase); 00122 o.fill(' '); 00123 00124 o.setf(ios::scientific); 00125 o.setf(ios::showpos); 00126 o.unsetf(ios::fixed); 00127 00128 u32 cell_width; 00129 00130 o.precision(3); 00131 cell_width = 2 + 2*(1 + 3 + o.precision() + 5) + 1; 00132 00133 return cell_width; 00134 }
arma_inline void arma_ostream::print_elem | ( | std::ostream & | o, | |
const eT & | x | |||
) | [inline, static, inherited] |
Print an element to the specified stream.
Definition at line 142 of file arma_ostream_meat.hpp.
Referenced by print().
arma_inline void arma_ostream::print_elem | ( | std::ostream & | o, | |
const std::complex< T > & | x | |||
) | [inline, static, inherited] |
Print a complex element to the specified stream EXPERIMENTAL !
Definition at line 154 of file arma_ostream_meat.hpp.
void arma_ostream::print | ( | std::ostream & | o, | |
const Mat< eT > & | m, | |||
const bool | modify | |||
) | [inline, static, inherited] |
Print a matrix to the specified stream.
Definition at line 172 of file arma_ostream_meat.hpp.
References Mat< eT >::at(), Mat< eT >::memptr(), modify_stream(), Mat< eT >::n_cols, Mat< eT >::n_elem, Mat< eT >::n_rows, print_elem(), and arma_ostream_state::restore().
Referenced by operator<<(), and print().
00173 { 00174 arma_extra_debug_sigprint(); 00175 00176 const arma_ostream_state stream_state(o); 00177 00178 u32 cell_width; 00179 00180 if(modify == true) 00181 { 00182 cell_width = arma_ostream::modify_stream(o, m.memptr(), m.n_elem); 00183 } 00184 else 00185 { 00186 cell_width = o.width(); // copy the user's cell width 00187 } 00188 00189 if(cell_width > 0) 00190 { 00191 for(u32 row=0; row < m.n_rows; ++row) 00192 { 00193 for(u32 col=0; col < m.n_cols; ++col) 00194 { 00195 // the cell width appears to be reset after each element is printed, 00196 // hence we need to restore it 00197 o.width(cell_width); 00198 arma_ostream::print_elem(o, m.at(row,col)); 00199 } 00200 00201 o << '\n'; 00202 } 00203 } 00204 else 00205 { 00206 for(u32 row=0; row < m.n_rows; ++row) 00207 { 00208 for(u32 col=0; col < m.n_cols-1; ++col) 00209 { 00210 arma_ostream::print_elem(o, m.at(row,col)); 00211 o << ' '; 00212 } 00213 00214 arma_ostream::print_elem(o, m.at(row, m.n_cols-1)); 00215 o << '\n'; 00216 } 00217 } 00218 00219 o.flush(); 00220 stream_state.restore(o); 00221 }
void arma_ostream::print | ( | std::ostream & | o, | |
const Cube< eT > & | m, | |||
const bool | modify | |||
) | [inline, static, inherited] |
Print a cube to the specified stream.
Definition at line 229 of file arma_ostream_meat.hpp.
References Cube< eT >::memptr(), modify_stream(), Cube< eT >::n_elem, Cube< eT >::n_slices, print(), arma_ostream_state::restore(), and Cube< eT >::slice().
00230 { 00231 arma_extra_debug_sigprint(); 00232 00233 const arma_ostream_state stream_state(o); 00234 00235 u32 cell_width; 00236 00237 if(modify == true) 00238 { 00239 cell_width = arma_ostream::modify_stream(o, x.memptr(), x.n_elem); 00240 } 00241 else 00242 { 00243 cell_width = o.width(); 00244 } 00245 00246 for(u32 slice=0; slice < x.n_slices; ++slice) 00247 { 00248 o << "[cube slice " << slice << ']' << '\n'; 00249 o.width(cell_width); 00250 arma_ostream::print(o, x.slice(slice), false); 00251 o << '\n'; 00252 } 00253 00254 stream_state.restore(o); 00255 }
void arma_ostream::print | ( | std::ostream & | o, | |
const field< oT > & | m | |||
) | [inline, static, inherited] |
Print a field to the specified stream Assumes type oT can be printed, i.e. oT has std::ostream& operator<< (std::ostream&, const oT&).
Definition at line 265 of file arma_ostream_meat.hpp.
References field< oT >::at(), field< oT >::n_cols, field< oT >::n_rows, and arma_ostream_state::restore().
00266 { 00267 arma_extra_debug_sigprint(); 00268 00269 const arma_ostream_state stream_state(o); 00270 00271 const std::streamsize cell_width = o.width(); 00272 00273 for(u32 col=0; col<x.n_cols; ++col) 00274 { 00275 o << "[field column " << col << ']' << '\n'; 00276 for(u32 row=0; row<x.n_rows; ++row) 00277 { 00278 o.width(cell_width); 00279 o << x.at(row,col) << '\n'; 00280 } 00281 00282 o << '\n'; 00283 } 00284 00285 o.flush(); 00286 stream_state.restore(o); 00287 }
void arma_ostream::print | ( | std::ostream & | o, | |
const subview_field< oT > & | m | |||
) | [inline, static, inherited] |
Print a subfield to the specified stream Assumes type oT can be printed, i.e. oT has std::ostream& operator<< (std::ostream&, const oT&).
Definition at line 296 of file arma_ostream_meat.hpp.
References subview_field< oT >::at(), subview_field< oT >::n_cols, subview_field< oT >::n_rows, and arma_ostream_state::restore().
00297 { 00298 arma_extra_debug_sigprint(); 00299 00300 const arma_ostream_state stream_state(o); 00301 00302 const std::streamsize cell_width = o.width(); 00303 00304 for(u32 col=0; col<x.n_cols; ++col) 00305 { 00306 o << "[subfield column " << col << ']' << '\n'; 00307 for(u32 row=0; row<x.n_rows; ++row) 00308 { 00309 o.width(cell_width); 00310 o << x.at(row,col) << '\n'; 00311 } 00312 00313 o << '\n'; 00314 } 00315 00316 o.flush(); 00317 stream_state.restore(o); 00318 }