|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: Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>
- Date: Mon, 8 Mar 2010 14:45:39 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.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=ULkvMY/wIWGRe6J5WwNRxX31klcyIzILOlf3itpZ5Y4=; b=i34BUzbAYjOAj1EauWnM0SEQoEGzBH1vzb3+dzxJ07wOFO3D+gO6FVRJR5lo0p9L92 yNtR0s3NG7qNv+HRBQ9S7zy0PQ62jF1276If2M7G6qXrPL1/eDwW0s3+OQ2r7WPkyFDj W15e+TM6hsYnO5BoXNtIBHWDNibydzfgjJjAA=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=soT0Cj02fWlTu7T8bQ0TDX096ldfBfig2prpEM9HCkcEa5cqgs2o7jqZd52n8tG1ls RuWiqzKqRI5Hpjtdt7BnzJ3WgiweO6XTZEiY+YEGlQmU0JQFUa/WYrPJLZ8+NAJSgpFb HQjbFzAEczNIhPb15ZrzkSdZ7JDZg8q+l0/AA=
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().
Hope that helps...
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