|Re: [eigen] resizing in ReturnByValue assignment|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] resizing in ReturnByValue assignment
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Mon, 8 Mar 2010 09:15:45 -0500
- 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=oE1cuqHoyToqZjFD7dAklSyzCQRK/RNAUBmA89ZOGXU=; b=sUMfP1uXCZFy+yj2qB6Tb0EUbkbTwu+XiDp4NjZzfM0t4l8SPXC+lGqXYGaohwfVtF 4T+VRQNJ3ydMpQ+4mWL+MuSVgjwHE7EFmZZ9ngYk9x/nQXqfQ0umRkoo7wVJoOW3eygm aqe55DgdTjprkCwno+LhuRQicl3SfsYMnZeY0=
- 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=vdkgX5YXq7mqwuB/s8+R0btYflXy5Eg6i6JM6k3lgTpyA22cHWBbFiGrk+QBhNwARd iS49f7p0h/Oo63a48HTWa6+GBR30jjNMeQ0LEV95Lw1p9gRoN3msqYo42Zz68diWzoaR bZl7DxrxOpebNMGf7rqCj/BYRab5kRM0jdO+4=
2010/3/8 Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>:
> Resize should be almost like a nullary op when the destination object
> already has correct size - if it is not, this is a bug. The advantage
> of having the assignment operator doing the resizing is that you
> cannot forget about it when implementing ReturnByValue since you
> simply don't need to take care of it.
> Regarding the confusion about rows()/cols() you have to think of
> ReturnByValue as your actual result and thus this object should also
> be reflecting your result's properties as e.g. rows() and cols().
exactly... think for example of the case where you are using your
returnByValue object in some expression that wants to evaluate it as a
temporary (as is automatic when nesting ReturnByValue into a bigger
expression)... then it needs to know the dimensions of the temporary
matrix to create!
> Hope that helps...
> - Hauke
> On Mon, Mar 8, 2010 at 2:33 PM, Mark Borgerding <mark@xxxxxxxxxxxxxx> wrote:
>> First, the praise: I really like the ReturnByValue paradigm. It is
>> syntactically cleaner than using the destination-as-an-argument. It bends
>> the rules of c++ somewhat and allows one to overload/specialize based on
>> return type. Very cool.
>> Next, my confusion:
>> Eigen::FFT fwd,inv now uses ReturnByValue but it elicits an unnecessary
>> resize in some conditions (eliminating the advantage of the ReturnByValue
>> proxy object). This is my bug -- I thought the rows() and cols() referred to
>> the source matrix. They refer to the destination. I can fix this by
>> duplicating the logic required to decide the output size from the FFT fwd
>> and inv functions, but I'm lazy and I don't like doing work I don't need to
>> Why does DenseStorageBase::operator=( ReturnByValue ) call resize() first?
>> (defined in Eigen/src/Core/DenseStorageBase.h around line 300)
>> Why not just require the ReturnByValue subclass evalTo method resize the
>> destination as needed?
>> Removing the resize also simplifies the implementation slightly by
>> eliminating the need for rows() and cols() to be defined in the
>> ReturnByValue subclass.
>> Am I missing something?
>> -- Mark Borgerding