Classes | |
class | arma_ostream_state |
class | arma_ostream |
Functions | |
template<typename T1 > | |
std::ostream & | operator<< (std::ostream &o, const Op< T1, op_diagmat > &X) |
Print a diagonal matrix to the specified stream. | |
template<typename T1 > | |
std::ostream & | operator<< (std::ostream &o, const field< T1 > &X) |
Print the contents of a field to the specified stream Assumes type T1 can be printed, i.e. T1 has std::ostream& operator<< (std::ostream&, const T1&). | |
template<typename T1 > | |
std::ostream & | operator<< (std::ostream &o, const subview_field< T1 > &X) |
Print the contents of a subfield to the specified stream Assumes type T1 can be printed, i.e. T1 has std::ostream& operator<< (std::ostream&, const T1&). | |
template<typename eT > | |
std::ostream & | operator<< (std::ostream &o, const Mat< eT > &m) |
template<typename T1 > | |
std::ostream & | operator<< (std::ostream &o, const Base< typename T1::elem_type, T1 > &X) |
template<typename eT > | |
static u32 | arma_ostream::modify_stream (std::ostream &o, const Mat< eT > &m) |
template<typename T > | |
static u32 | arma_ostream::modify_stream (std::ostream &o, const Mat< std::complex< T > > &m) |
"better than nothing" settings for complex numbers | |
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 T > | |
static void | arma_ostream::print (std::ostream &o, const Mat< std::complex< T > > &m, const bool modify) |
Print a complex matrix to the specified stream EXPERIMENTAL ! |
std::ostream& operator<< | ( | std::ostream & | o, | |
const Op< T1, op_diagmat > & | X | |||
) | [inline] |
Print a diagonal matrix to the specified stream.
Definition at line 24 of file ostream_diagmat.hpp.
References Mat< eT >::at(), Mat< eT >::is_square(), Mat< eT >::is_vec(), max(), Mat< eT >::mem, arma_ostream::modify_stream(), Mat< eT >::n_cols, and Mat< eT >::n_rows.
00025 { 00026 arma_extra_debug_sigprint(); 00027 00028 typedef typename T1::elem_type eT; 00029 00030 const unwrap<T1> tmp(X.m); 00031 const Mat<eT>& m = tmp.M; 00032 00033 arma_debug_check( ((m.is_vec() == false) && (m.is_square() == false)), "operator<<(): incompatible dimensions for diagmat operation" ); 00034 00035 const arma_ostream_state stream_state(o); 00036 00037 const u32 cell_width = arma_ostream::modify_stream(o, m); 00038 00039 const u32 local_n_rows = (std::max)(m.n_rows, m.n_cols); 00040 00041 for(u32 row=0; row < local_n_rows; ++row) 00042 { 00043 for(u32 col=0; col < local_n_rows; ++col) 00044 { 00045 if(row != col) 00046 { 00047 o.width(cell_width); 00048 if(is_complex<eT>::value == false) 00049 { 00050 o << "0.0"; 00051 } 00052 else 00053 { 00054 o << "(0.0,0.0)"; 00055 } 00056 } 00057 else 00058 { 00059 const eT val = m.is_vec() ? m.mem[row] : m.at(row,row); 00060 00061 o.width(cell_width); 00062 o << val; 00063 } 00064 } 00065 o << '\n'; 00066 } 00067 00068 o.flush(); 00069 00070 stream_state.restore(o); 00071 00072 return o; 00073 }
std::ostream& operator<< | ( | std::ostream & | o, | |
const field< T1 > & | X | |||
) | [inline] |
Print the contents of a field to the specified stream Assumes type T1 can be printed, i.e. T1 has std::ostream& operator<< (std::ostream&, const T1&).
Definition at line 26 of file ostream_field.hpp.
00027 { 00028 arma_extra_debug_sigprint(); 00029 00030 for(u32 col=0; col<X.n_cols; ++col) 00031 { 00032 o << "[field column " << col << ']' << '\n'; 00033 for(u32 row=0; row<X.n_rows; ++row) 00034 { 00035 o << X.at(row,col) << '\n'; 00036 } 00037 00038 o << '\n'; 00039 } 00040 00041 o.flush(); 00042 00043 return o; 00044 }
std::ostream& operator<< | ( | std::ostream & | o, | |
const subview_field< T1 > & | X | |||
) | [inline] |
Print the contents of a subfield to the specified stream Assumes type T1 can be printed, i.e. T1 has std::ostream& operator<< (std::ostream&, const T1&).
Definition at line 54 of file ostream_field.hpp.
00055 { 00056 arma_extra_debug_sigprint(); 00057 00058 for(u32 col=0; col<X.n_cols; ++col) 00059 { 00060 for(u32 row=0; row<X.n_rows; ++row) 00061 { 00062 o << X.at(row,col) << '\n'; 00063 } 00064 00065 o << '\n'; 00066 } 00067 00068 o.flush(); 00069 00070 return o; 00071 }
std::ostream& operator<< | ( | std::ostream & | o, | |
const Mat< eT > & | m | |||
) | [inline] |
Definition at line 282 of file ostream_mat.hpp.
References arma_ostream::print().
00283 { 00284 arma_extra_debug_sigprint(); 00285 00286 arma_ostream::print(o,m,true); 00287 00288 return o; 00289 }
std::ostream& operator<< | ( | std::ostream & | o, | |
const Base< typename T1::elem_type, T1 > & | X | |||
) | [inline] |
Definition at line 22 of file ostream_misc.hpp.
00023 { 00024 arma_extra_debug_sigprint(); 00025 00026 const unwrap<T1> tmp(X.get_ref()); 00027 00028 o << tmp.M; 00029 00030 return o; 00031 }
u32 arma_ostream::modify_stream | ( | std::ostream & | o, | |
const Mat< eT > & | m | |||
) | [inline, static, inherited] |
Definition at line 77 of file ostream_mat.hpp.
References Mat< eT >::mem, and Mat< eT >::n_elem.
Referenced by operator<<(), and arma_ostream::print().
00078 { 00079 o.unsetf(ios::showbase); 00080 o.unsetf(ios::uppercase); 00081 o.fill(' '); 00082 00083 u32 cell_width; 00084 00085 bool use_layout_B = false; 00086 bool use_layout_C = false; 00087 00088 for(u32 i=0; i<m.n_elem; ++i) 00089 { 00090 const eT val = m.mem[i]; 00091 00092 if( 00093 val >= eT(+100) || 00094 ( (is_signed<eT>::value == true) && (val <= eT(-100)) ) || 00095 ( (is_non_integral<eT>::value == true) && (val > eT(0)) && (val <= eT(+1e-4)) ) || 00096 ( (is_non_integral<eT>::value == true) && (is_signed<eT>::value == true) && (val < eT(0)) && (val >= eT(-1e-4)) ) 00097 ) 00098 { 00099 use_layout_C = true; 00100 break; 00101 } 00102 00103 if( 00104 (val >= eT(+10)) || ( (is_signed<eT>::value == true) && (val <= eT(-10)) ) 00105 ) 00106 { 00107 use_layout_B = true; 00108 } 00109 } 00110 00111 if(use_layout_C == true) 00112 { 00113 o.setf(ios::scientific); 00114 o.unsetf(ios::fixed); 00115 o.precision(4); 00116 cell_width = 13; 00117 } 00118 else 00119 if(use_layout_B == true) 00120 { 00121 o.unsetf(ios::scientific); 00122 o.setf(ios::fixed); 00123 o.precision(4); 00124 cell_width = 10; 00125 } 00126 else 00127 { 00128 o.unsetf(ios::scientific); 00129 o.setf(ios::fixed); 00130 o.precision(4); 00131 cell_width = 9; 00132 } 00133 00134 return cell_width; 00135 }
u32 arma_ostream::modify_stream | ( | std::ostream & | o, | |
const Mat< std::complex< T > > & | m | |||
) | [inline, static, inherited] |
"better than nothing" settings for complex numbers
Definition at line 143 of file ostream_mat.hpp.
00144 { 00145 o.unsetf(ios::showbase); 00146 o.unsetf(ios::uppercase); 00147 o.fill(' '); 00148 00149 o.setf(ios::scientific); 00150 o.setf(ios::showpos); 00151 o.unsetf(ios::fixed); 00152 00153 u32 cell_width; 00154 00155 o.precision(3); 00156 cell_width = 2 + 2*(1 + 3 + o.precision() + 5) + 1; 00157 00158 return cell_width; 00159 }
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 167 of file ostream_mat.hpp.
References Mat< eT >::at(), arma_ostream::modify_stream(), Mat< eT >::n_cols, Mat< eT >::n_rows, and arma_ostream_state::restore().
Referenced by operator<<().
00168 { 00169 arma_extra_debug_sigprint(); 00170 00171 const arma_ostream_state stream_state(o); 00172 00173 u32 cell_width; 00174 00175 if(modify == true) 00176 { 00177 cell_width = arma_ostream::modify_stream(o, m); 00178 } 00179 else 00180 { 00181 cell_width = o.width(); 00182 } 00183 00184 if(cell_width != 0) 00185 { 00186 for(u32 row=0; row < m.n_rows; ++row) 00187 { 00188 for(u32 col=0; col < m.n_cols; ++col) 00189 { 00190 o.width(cell_width); 00191 o << m.at(row,col); 00192 } 00193 00194 o << '\n'; 00195 } 00196 } 00197 else 00198 { 00199 for(u32 row=0; row < m.n_rows; ++row) 00200 { 00201 for(u32 col=0; col < m.n_cols-1; ++col) 00202 { 00203 o << m.at(row,col) << ' '; 00204 } 00205 00206 o << m.at(row, m.n_cols-1) << '\n'; 00207 } 00208 } 00209 00210 o.flush(); 00211 stream_state.restore(o); 00212 }
void arma_ostream::print | ( | std::ostream & | o, | |
const Mat< std::complex< T > > & | m, | |||
const bool | modify | |||
) | [inline, static, inherited] |
Print a complex matrix to the specified stream EXPERIMENTAL !
Definition at line 221 of file ostream_mat.hpp.
References arma_ostream::modify_stream(), and arma_ostream_state::restore().
00222 { 00223 arma_extra_debug_sigprint(); 00224 00225 const arma_ostream_state stream_state(o); 00226 00227 u32 cell_width; 00228 00229 if(modify == true) 00230 { 00231 cell_width = arma_ostream::modify_stream(o, m); 00232 } 00233 else 00234 { 00235 cell_width = o.width(); 00236 } 00237 00238 00239 00240 if(cell_width != 0) 00241 { 00242 for(u32 row=0; row < m.n_rows; ++row) 00243 { 00244 for(u32 col=0; col < m.n_cols; ++col) 00245 { 00246 std::ostringstream ss; 00247 ss.flags(o.flags()); 00248 //ss.imbue(o.getloc()); 00249 ss.precision(o.precision()); 00250 00251 ss << '(' << m.at(row,col).real() << ',' << m.at(row,col).imag() << ')'; 00252 00253 o.width(cell_width); 00254 o << ss.str(); 00255 } 00256 00257 o << '\n'; 00258 } 00259 } 00260 else 00261 { 00262 for(u32 row=0; row < m.n_rows; ++row) 00263 { 00264 for(u32 col=0; col < m.n_cols-1; ++col) 00265 { 00266 o << '(' << m.at(row,col).real() << ',' << m.at(row,col).imag() << ") "; 00267 } 00268 o << '(' << m.at(row, m.n_cols-1).real() << ',' << m.at(row, m.n_cols-1).imag() << ")\n"; 00269 } 00270 } 00271 00272 00273 o.flush(); 00274 stream_state.restore(o); 00275 }