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 09:13:28 -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=ktm7sg5FN7pGc8W5Jl/NERu8FjyXrojpFxADQyfNjeE=; b=DBQtEom+Wv4SgJyZlaySO95WAr/HOyyhHgtdqQOAocL8vm4ilg0DFZM2nqT+VQb0Sa c68Jh82RJZSYfKpIB23nqtRE36VBHOpxdMy+eNEmH6s+B32mwyL8AmvNFa371XPp2mot fCfrXcpRzKvuTFh0un12abOjn6PN/2u9zPTvo=
- 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=pUU6bf1vqwmle/N6xhw5+RZJVPzduOQlwnWNHt8+6w9W3I/xdxcfnI3aBdkSpNBmhs XZTMo9dHWGOLHQYWTWaKkQJqvpKaMb6IKZqywDXo2Jnndaqp7aYVPng6bitTWaneSKS5 cFlGJFpTI1RhEil5K75m1dhFwgQKb5myzQX64=
2009/9/11 Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>:
> On Fri, Sep 11, 2009 at 2:15 PM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
>> Hey, what do you think about renaming .ref() by .inplace() in this
>> case? Then this API looks quite good to me:
>>
>> A.solve(b.inplace());
>>
>> I'd be OK with that API, actually I think that it's not even
>> significantly heavier than the plain-c++-reference option,
>> A.solveInPlace(b).
>
> But isn't that from an effort point of view again a little bit
> overkill. You would need to introduce a new class just in order to be
> able to write .inplace() instead of solveInPlace(). I would prefer
> A.solveInPlace(b)...
>
> Also, looking back at the discussion on clean output arguments - what
> was again the reason to pass a const reference to swap (first e-mail
> by Gael, case 3)?? The implementation is involving a const_cast! I
> mean swap changes the data. What am I missing?
>
> Currently, I completely fail to see arguments for ref(), inout() or
> similar... can we not just use the 'const' keyword to make it crystal
> clear when something is an output and when it is not?
The common answer to all your questions is that C++ has a very, very
stupid rule that one can't take a non-constant reference to a
temporary.
So when we do matrix.row(i).swap(matrix.row(j)), the method row()
returns a temporary and we can't take a non-const reference to it. So
my dirty workaround was to pass a const reference just to appease the
gods of c++ and then const-cast. Then Gael came by and proposed his
Reference (or Output) little class that is a trivial wrapper around a
reference, that we can pass by value. (It remains to be seen how we
can make swap use such an idea).
Same thing when we do A.solveInPlace(b.start(n)), start() returns a
temporary, same problem, whence the idea of inplace() or whatever we
call it.
Benoit