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.
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.
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.