|Re: [eigen] Undesired formatting behaviour|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Undesired formatting behaviour
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Wed, 25 Feb 2009 02:45:08 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=UEn53itfm5tzwfKjgHEP2B5HPaHgu4OeeHfbmRsD6UA=; b=SXHOkziE2czeM9sOp2PL5sy1tmnuRoGx+B3QnMx23v7SvVROs/flbAXmUhGpdgRJJf 3AlyeLEkxG4misOuF9PeDG7CQTHGktjvqib37hJhWfwZ1X+uMaW3Pl9cqXHckWgecbS6 fC4atbo9KEbf1+oe2ZVkreGdIPMaTZ1PSJ3Vs=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=ntDcL5JbUgJalG9Da10qTlTGSafC8huTsqPFIkei7xe0xcntBD4K0GvsjYTMp6xfr0 Nq2XiA4XRhhEaFeiPA9bCulnIhOZNgIZ4gGErNkf1lPW7CJD9/l9m7TMqjKyK4bearLz WKYirqIFM2ln82F9OxiLnHbCFnD09dkOXxt4A=
On Tue, Feb 24, 2009 at 7:24 PM, Johan Pauwels
> Hi all,
> int width = 0 by int width = s.width(); s.width(0); on line 129 of
> Eigen/src/Core/io.h gave me the result I intended. As far as I can see, this
> patch is compatible with the concept of IOFormat (of which I learned later
> on), since the default width of 0 has no effect.
I agree with that change.
> A similar, but more debatable case is that of ostream.precision(). If you
> specify the precision like cout << setprecision(3) << matrix; it gets
> ignored. The difference with the width case is that I cannot think of a
> straightforward patch that would add this functionality without changing the
> behaviour of IOFormat, since there is no "neutral" value for precision such
> as width(0) is. I guess the thing to do would be to initialise the default
> matPrefix to a to be defined special symbol that tells to take the current
> precision of the ostream when writing to that stream.
I understand your concerns and I think that's generally a good idea to
add default parameter values which would mean "use the respective
setting of the ostream object".
> What I consider an inconsistency is that you use the IOFormat class at all
> to define the precision, since you still are dependent on the floatfield
> flag of the stream to use the precision you define in IOFormat. I mean, you
> still need to write cout << fixed << matrix; before the precision gets used
> with floats for example. Either you define all the formatting behaviour in
> the IOFormat class and inhibit the effects of the ostream flags or you read
> all ostream flags and act accordingly (where I'd prefer the latter). The
> AlignCols flag has added value compared to a simple width(x), so to put that
> into IOFormat makes sense to me in both cases.
the main goal of the current design was to be able to define a format
object once and use it many times. This is why all options are
encapsulated in IOFormat.
> Either way, a trivial feature
> request is that I'd like setters for the variables in IO Format such that you
> can initialise with the default IOFormat() format; and just change the one
> variable you want with format.setRowPrefix = "pre"; for example.
no problem to add such setters, a patch would be very much appreciated ;)
> A last, completely unrelated thing is that I can find how to take the sum of
> a matrix, but not the product of the matrix. It could be that I'm looking
> over it, but if not, it's another feature request.
in svn trunk we have the prod() function which does exactly that.
> I hope this comes over as some constructive criticism as I intend it to be,
> because overall I think it is a terribly well done, feature-complete and
> elegant library.
constructive remarks are always very welcomed :)