This bugzilla service is closed. All entries have been migrated to
Bug 423 - Choose rows/columns from a WithFormat expression
Summary: Choose rows/columns from a WithFormat expression
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: unspecified
Hardware: All All
: Low Feature Request
Assignee: Nobody
Keywords: JuniorJob
Depends on:
Reported: 2012-02-22 16:09 UTC by timmyl17
Modified: 2019-12-04 11:28 UTC (History)
3 users (show)


Description timmyl17 2012-02-22 16:09:35 UTC
This is just a convenience request. I often want to print matrices with different headers for each row, something like

controls  :  <matrix row 1>
gradients :  <matrix row 2>

I can do this by printing each row separately

cout << "controls  : " << Mat.row(0) << endl
     << "gradients : " << Mat.row(1) << endl;

But then the columns are not aligned. Even if I use an IOFormat object for each row, the columns are not aligned properly if the maximum element size in each row is not equal. It would be convenient if we could call block operations like row or col on WithFormat expressions, something like

cout << "controls  : " << Mat.format(fmt).row(0) << endl
     << "gradients : " << Mat.format(fmt).row(1) << endl;

which would align the columns properly. I think this could also be solved (I'm guessing easier for the developers) by having a parameter in IOFormat which specifies the field width, instead of just the number of significant digits. Also, with a field width parameter, it would be possible to correctly align separate matrices or vectors without concatenating them into one large matrix.

Comment 1 Christoph Hertzberg 2014-12-01 16:00:48 UTC
Probably in this case it would be easier to directly set the width of the stream and let Eigen output without alignment (not tested).

But if someone cares to implement this, I would not object. 
Some difficulties:
Mat.format(fmt) would have to be responsible for calculating the maximal width of the entries, but this probably won't work if fmt uses StreamPrecision. Also, what shall happen if between different calls the precision of the stream is changed?
What shall happen if an entry does not fit into the desired width?

So indeed maybe only adding a width instead of or additionally to the precision value would be a better alternative here.
Comment 2 Nobody 2019-12-04 11:28:57 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance:

Note You need to log in before you can comment on or make changes to this bug.