Re: [eigen] Lazy evaluation bug, feature, or PEBKAC? |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Lazy evaluation bug, feature, or PEBKAC?
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Wed, 2 Mar 2011 13:45:11 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=DErgf0pz7WZB2wB6oPK4i5jkNI9y3gr0lZYSMB5PsF4=; b=NavmXCs7o8QAmDtPGkXAhTW6rFZv006SWRZD0G+RdZqCmQF2NEgdHLOXOJWwp9w+hD dDlZQe+wmhvoWMG1PEDXEm/3U113cIZ426M+FuqSQnxfLFv2pcOSNxO6ZlDEBhKwOqzy sDHxao/HXlzJeiGwHyRleYGLz8v+lcHD7QcCk=
- 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=bXWSSCvUZWTSRL1XNntyB676Ogl3AqIq6xWducHVvj44kK2sz0OL0BlojYHSXIWUfP N6CUjhin9AGhTt/r1NjfInlGRNFDm7hiC7iwJFq4y+bzMZ1Zbu3GxyQIfBQTC17RVbWo G9THai/Hfks9YGDnRlDi9N/bsCjmNKZiqvJH8=
2011/3/2 Dave Steffen <dave.steffen@xxxxxxxxxxx>:
> On Wednesday, March 02, 2011 11:07:19 am Benoit Jacob wrote:
>> 2011/3/2 Benoit Jacob <jacob.benoit.1@xxxxxxxxx>:
>> > 2011/3/2 Dave Steffen <dave.steffen@xxxxxxxxxxx>:
>> >> On Wednesday, March 02, 2011 02:31:40 am Gael Guennebaud wrote:
>
> [...]
>
>> >> In my application, I really *do* need to add two matrices, which
>> >> might or might not happen to have 1 column, and then operate
>> >> (read-only) on individual columns. That doesn't strike me as a
>> >> terribly unusual thing to do.
>> >
>> > The unusual thing here is to want to construct the expression object
>> > once and then reuse it.
>> >
>> > Constructing these expression objects has zero runtime cost in
>> > optimized builds, because we make it very easy for the compiler to
>> > optimize away the expression objects completely.
>> >
>> > Therefore, there is no overhead in doing "a+b" everytime you need this
>> > sum expression: zero overhead.
>> >
>> > That's why practically nobody is trying to do what you're doing here :)
>>
>> Also, note that your code only looks "natural" because it's using the
>> C++0x auto keyword. The C++03 version would have to name explicitly
>> the (very abstruse) expression type, which is another reason why
>> practically nobody bothers.
>
> Riiiight. That is, I shouldn't be stashing a ref to an
> *expression*, I need to be evaluating that expression into a Matrix.
Either that, or do what I suggested in my previous email: just write
(a+b).col(0) everytime. Neither the operator+ nor the col() method
have any cost at runtime.
Benoit
>
> Being new to Eigen, it didn't occur to me that keeping refs to
> expressions could wreak so much havoc.
>
> So: the actual answer to my question is both "bug" and "PEBKAC",
> the latter problem to be resolved by the usual statement: "don't do
> that".
>
> :-)
>
> --
> Dave Steffen, Ph.D. - Software Engineer
>
> Numerica Corporation <http://www.numerica.us>
> 4850 Hahns Peak Drive, Suite 200
> Loveland, Colorado 80538
> main (970) 461-2000 x 227 direct (970) 612-2327
> Email: dave.steffen@xxxxxxxxxxx
> fax (970) 461-2004
>
> This message and any attachments are intended only for the individual
> or entity to which the message is addressed. This is a private
> message and may contain privileged information. If you are neither
> the intended recipient nor the agent responsible for delivering the
> message to the intended recipient, you are hereby notified that any
> review, retransmission, dissemination, or taking of any action in
> reliance upon, the information in this communication is strictly
> prohibited, and may be unlawful. If you feel you have received this
> communication in error, please notify me immediately by returning this
> email to me and deleting it from your computer.
>
>
>