This forum has been archived. All content is frozen. Please use KDE Discuss instead.

std::cout precision

Tags: None
(comma "," separated)
MarkusS
Registered Member
Posts
9
Karma
0
OS

std::cout precision

Tue Nov 10, 2009 4:52 pm
Hi,

I have a small problem with printing of MatrixXd and VectorXd objects via std::cout:
I can't change the precision of the elements. Even after the statements:
Code: Select all
 std::cout.precision(11);
std::cout.setf(std::ios::scientific, std::ios::floatfield);

a MatrixXd or VectorXd object is only printed with 4 digits. Switching to scientific format works fine...

How do I get more digits?
(BTW, this is on Mac OS X 10.6.1 using gcc 4.2.1 and eigen 2.0.9)

Thanks,

Markus
User avatar
bjacob
Registered Member
Posts
658
Karma
3

Re: std::cout precision

Tue Nov 10, 2009 6:46 pm
Yeah, the 2.0 version is a bit stupid in that it doesn't honor cout.precision().

With 2.0, to change the precision you have to use a IOFormat, see the docs for that class, and see MatrixBase::format().

With the development branch, cout.precision() is honored by default.


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!


Bookmarks



Who is online

Registered users: Bing [Bot], daret, Google [Bot], sandyvee, Sogou [Bot]