Re: [eigen] still the solve() API debate |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] still the solve() API debate
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Fri, 11 Sep 2009 14:49:20 -0400
- 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; bh=84lPYmiJ4xQw2IR3/oPzRbSjkgmSfUC+1VQXcgQ1Yjw=; b=wio+W7oR9oXd9blQmeaLw5H07SiZMAM/qlN6hqaoIndotbQZT1UuTJY7NmyNXvTHMW bLLGtRZJoMVqhT6RQdX9KbuI4JEF0dmiVtUBBeEEmUIQ70Ugk0Y/oRngbDt2hRgz5vct STcIybLGbv+wuwvNX8yqFVmkJvLSVHYYT68dI=
- 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; b=u78x1ugA3zE3w/TgIOJ6EhLzkkLGtQIEAt2VWM+pdI1cuPC9e9bBpQpoYLq5tocujo x5k4n8ihfO5JAZVkT5bK46fLLRLVX7HNbq+G1dy4ZiGAUm1vtMeufrHY3B8MwBm8A0/3 nNs+RN/8j9lJcmrHHtQZCn99SJ3T23/ACXhno=
2009/9/11 Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>:
> On Fri, Sep 11, 2009 at 5:17 PM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
>> OK, coming back to seriousness: I like your idea, I'm just not sure
>> about the INOUT name. Maybe the more verbose EIGEN_REF_TO_TEMPORARY
>> would be more explicit as to what it does and why we have to do it?
>
> Of course, anything would be fine here...
>
>> +1 to Hauke's idea to keep rvalue refs in mind;
>
> Actually Gael's, I just moved the const. :)
>
> Ok, I just did some reading (this is a cool article:
> http://blogs.msdn.com/vcblog/archive/2009/02/03/rvalue-references-c-0x-features-in-vc10-part-2.aspx)
> and then I recalled something from "Effective STL" which confused me a
> bit. One item in "Effective STL" deals with "the swap trick" to trim
> the capacity of std::vector....
>
> Now I was wondering how this should work facing the rvalue issue we
> are having with swap since the idea is to swap a vector with a
> temporary rvalue object that is empty. After looking at the
> std::vector::swap implementation I recognized that it is implemented
> as expected with a non-const reference, so how can this work? Well,
> swap is commutative and what they do is simply to put the rvalue
> object on the left-hand-side like this:
>
> std::vector<double> v(10000,1.0);
> std::vector<double>().swap(v); // as opposed to ...
> // v.swap(std::vector<double>())
>
> So, now I am just asking... could we not just use void
> MatrixBase::swap(MatrixBase<OtherDerived>& other) and force the user
> to use e.g.
>
> MatrixXf a,b,c;
> (a*b).swap(c);
>
> I am just wondering...
But what happens when both sides are temporaries? As is the case with:
matrix.row(i).swap(matrix.row(j))
>
> Going back to the solve API. What about
>
> MagicReturnType<...> solve(const MatrixBase<...>& b) const; // and
> void solve(MatrixBase<...>& b) const;
>
> For the first one we may pass rvalue objects and everything is fine
> and for the second one, well, rvalue objects don't make any sense...
> so here we don't care.
precisely, Gael's point was that they do make sense, e.g.
A.solve(b.start(n))
and use cases come from the implementation of blocked algorithms.
Benoit