16enum { DontAlignCols = 1 };
17enum { StreamPrecision = -1,
21template<
typename Derived>
22std::ostream & print_matrix(std::ostream & s,
const Derived& _m,
const IOFormat& fmt);
63 if((flags & DontAlignCols))
65 int i = int(matSuffix.length())-1;
66 while (i>=0 && matSuffix[i]!=
'\n')
72 std::string matPrefix, matSuffix;
73 std::string rowPrefix, rowSuffix, rowSeparator, rowSpacer;
74 std::string coeffSeparator;
95template<
typename ExpressionType>
101 : m_matrix(matrix), m_format(format)
106 return internal::print_matrix(s,
wf.m_matrix.
eval(),
wf.m_format);
110 typename ExpressionType::Nested m_matrix;
119template<
typename Scalar>
122 static inline int run()
130template<
typename Derived>
131std::ostream & print_matrix(std::ostream & s,
const Derived&
_m,
const IOFormat&
fmt)
138 s <<
fmt.matPrefix <<
fmt.matSuffix;
142 typename Derived::Nested m =
_m;
143 typedef typename Derived::Scalar Scalar;
146 is_same<Scalar, char>::value ||
147 is_same<Scalar, unsigned char>::value ||
148 is_same<Scalar, numext::int8_t>::value ||
149 is_same<Scalar, numext::uint8_t>::value,
151 typename conditional<
164 if(
fmt.precision == StreamPrecision)
168 else if(fmt.precision == FullPrecision)
170 if (NumTraits<Scalar>::IsInteger)
172 explicit_precision = 0;
176 explicit_precision = significant_decimals_impl<Scalar>::run();
181 explicit_precision = fmt.precision;
184 std::streamsize old_precision = 0;
185 if(explicit_precision) old_precision = s.precision(explicit_precision);
187 bool align_cols = !(fmt.flags & DontAlignCols);
191 for(
Index j = 0; j < m.cols(); ++j)
192 for(
Index i = 0; i < m.rows(); ++i)
194 std::stringstream sstr;
196 sstr << static_cast<PrintType>(m.coeff(i,j));
197 width = std::max<Index>(width,
Index(sstr.str().length()));
200 std::streamsize old_width = s.width();
201 char old_fill_character = s.fill();
203 for(
Index i = 0; i < m.rows(); ++i)
212 s << static_cast<PrintType>(m.coeff(i, 0));
213 for(
Index j = 1; j < m.cols(); ++j)
215 s << fmt.coeffSeparator;
220 s << static_cast<PrintType>(m.coeff(i, j));
223 if( i < m.rows() - 1)
224 s << fmt.rowSeparator;
227 if(explicit_precision) s.precision(old_precision);
229 s.fill(old_fill_character);
248template<
typename Derived>
249std::ostream &
operator <<
253 return internal::print_matrix(s, m.eval(), EIGEN_DEFAULT_IO_FORMAT);
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:50
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EvalReturnType eval() const
Definition DenseBase.h:407
Namespace containing all symbols from the Eigen library.
Definition LDLT.h:16
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:74
Holds information about the various numeric (i.e.
Definition NumTraits.h:236