Re: [eigen] default printing format

[ Thread Index | Date Index | More Archives ]

On Thu, Aug 13, 2009 at 1:44 PM, Tim Hutt <tdhutt@xxxxxxxxx> wrote:
2009/8/13 Benoit Jacob <jacob.benoit.1@xxxxxxxxx>:
> Hi,
> Do you think that the default IOFormat should have alignment enabled,
> so that cout << matrix has aligned columns?
> Pro: looks much better
> Con: takes 2x more time, is useless when outputting to a file that's
> not meant to be read by a human

I think that should be the default. The most common use of cout is
probably debugging/logging/something else that is meant to be read by
a human. If you need to write a non-human-readable matrix really
quickly I think most people would use a binary format...


The defaults should address the 90% case, which is printing to the screen. If a user has sophisticated output needs, then they can change the code.
> While i'm here, here's another request i've received: that the default
> precision be full precision (e.g. 16 digits for double). Here i have a
> rather strong opinion against this, because the correct way to achieve
> this IMO is to set the stream's precision, so that not only Eigen
> matrices but all numbers use that precision. But i still wanted to run
> this request through this list in case I missed something.

I agree, for the same reason as above.

+1, to full precision default. To give an example why: I didn't even know streams *had* a precision setting! I suspect if you survey C++ programmers, a nontrivial fraction won't know the details of streams, and will expect full precision by default. Note that full precision is the default for the matrix-oriented processing system I've used, including matlab, octave, and numpy. In short, printing anything less than full precision by default violates the principle of least surprise.

Is there some way to detect that the stream has default precision? It's hard to say what the right behaviour is if there is no way to detect that the stream has default precision settings. If the stream has non-default precision settings, then we must follow them.


Mail converted by MHonArc 2.6.19+