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: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Fri, 11 Sep 2009 15:36:30 +0200
- 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=J/TohiM29gkI7DvEb5zLNCEhhI6Z1v3ZjI25k7jo01U=; b=wtQJ4KCpNsP38ZEUaNeriMpFENpOdHtXMnz0IvTfVOwJm9oH5mQ/Y7VjwMsGfluaxA 4/yzfyVY2qpxZddL1lHXQM5FUYtXj1XeUu/hLOVjcuDb672PCmbH82BV98pp5vhG5fxV OftXeXsiXvWKZ2a6xwhwINzhiBep7gWszi8Z0=
- 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=Tmfjw0BWN+5Pp8T7D5gTqwyLp4TQCQcb2UfEYdReygNhXj1DsmN0PjCYiyGNP/Vd0X tCSAdpvZqV+b+DT98SvHyQnfUFvRg4J1mMYJNRa8wsg6UcCNYy9p9a3ma+0vvkjeZ/Ti 7w1N9xhT1BAfh+3nZ4L5zPTLzOZSbaZagqgME=
On Fri, Sep 11, 2009 at 3:22 PM, Hauke Heibel
<hauke.heibel@xxxxxxxxxxxxxx> wrote:
> On Fri, Sep 11, 2009 at 3:13 PM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
>> 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.
>
> Ok, I just caught up with re-reading... that's indeed ugly. But as you
> guys already observed, in new compiler versions we already have rvalue
> references.
> Benoit, what about your idea of passing Matrices by
> reference and MatrixBase by value? You suggested to do that in the
> "MatrixBase::swap - why const" thread? This approach would allow an
> easy transition towards rvalues references in the future.
I've thought about it and I really don't see how to it safely and in a
generic way, and I really doubt that's possible.
I also have to say that my Reference<> solution becomes very tricky as
soon as you want to restrict your function to a MatrixBase<>, e.g.:
template<Derived> Derived& solve(Reference<Derived> b);
will match any type which can be explicitly converted to a Reference,
while we usually want to do:
template<Derived> Derived& solve(Reference<MatrixBase<Derived> > b);
but if you declare your function like this,
MatrixXf m;
A.solve(m.ref());
won't compile because the type of m.ref() is Reference<Matrix<...> >.
The unique way to make it working is to make Reference<Matrix<...> >
inheriting Reference<MatrixBase<Matrix<...> > >. (this is because the
solve function is template, and casting by inheritance is only kind of
casting which is allowed to select the function to instanciate)
That complicates the practical implementation of Reference<>. I'll
look into it more precisely.
gael.
> Hauke
>
>
>