From b2368b34089a4302cd4a5700f5b4b362d9ac8240 Mon Sep 17 00:00:00 2001 From: Christoph Hertzberg Date: Thu, 17 Oct 2013 14:30:09 +0200 Subject: [PATCH] Copy all format flags (not only precision) from actual output stream when calculating the maximal width --- Eigen/src/Core/IO.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Eigen/src/Core/IO.h b/Eigen/src/Core/IO.h index a7135a111..8d4bc59e9 100644 --- a/Eigen/src/Core/IO.h +++ b/Eigen/src/Core/IO.h @@ -185,6 +185,9 @@ std::ostream & print_matrix(std::ostream & s, const Derived& _m, const IOFormat& explicit_precision = fmt.precision; } + std::streamsize old_precision = 0; + if(explicit_precision) old_precision = s.precision(explicit_precision); + bool align_cols = !(fmt.flags & DontAlignCols); if(align_cols) { @@ -193,13 +196,11 @@ std::ostream & print_matrix(std::ostream & s, const Derived& _m, const IOFormat& for(Index i = 0; i < m.rows(); ++i) { std::stringstream sstr; - if(explicit_precision) sstr.precision(explicit_precision); + sstr.copyfmt(s); sstr << m.coeff(i,j); width = std::max(width, Index(sstr.str().length())); } } - std::streamsize old_precision = 0; - if(explicit_precision) old_precision = s.precision(explicit_precision); s << fmt.matPrefix; for(Index i = 0; i < m.rows(); ++i) {