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 17:08:07 +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=Vt41NsSJXeZnY20oFEAIn0/8jKTL/xk34/73px3Cxko=; b=fqfyEvCUs2MxhM4UYTx9JOHOwlNx+mi3MiTFWR7iTJa+KJCKq1+GLP2Wtsk0vcMjSO A2YEjmNGS/XPkokZlhxbKahYolffBX371duX9k6X+BcVgE2Y4a0f6asnrdhzmHIfRZdd hw1OGcIS1OC2Z6sQsAkoaXkjZ64wpW/1l310k=
- 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=FN87bqbXOYeEMOwQeJRIt+dl9AmZAMp4vqG9+2IFjdcktQT5G/JUYkwCtrCLnvOzvb ox5WE+xvhTzogE9mVGPd1roy1SSqTdPsE6sVP69+XsQXof/dSQ+XPAL5X6kB+FvBGym7 sFMgB1IhxotX1G7JGJuUcmCc3h+yOhU8/Sa94=
On Fri, Sep 11, 2009 at 4:54 PM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
> 2009/9/11 Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>:
>> On Fri, Sep 11, 2009 at 3:36 PM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
>>>> 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.
>>>
>>> That would be perfect, if you figure it out.
>>
>> Great, now I am confused again - just while thinking about it. :)
>>
>> Why not simply define swap as
>>
>> template <typename OtherDerived>
>> void swap(MatrixBase<OtherDerived> m);
>>
>> I mean in any case. It does not really matter whether a matrix is
>> passed or not - what we will copy is always only MatrixBase and that's
>> tiny, right?
>
> It can't be that simple: indeed MatrixBase is empty, it doesn't have
> data members. If things could work like this, then when copying the
> MatrixBase object we wouldn't copy any information, hence the matrix
> "m" would be completely forgotten.
>
> That said you raise my curiosity, i almost want to try a small program
> to see what happens (but in any case that can't work!) too bad i must
> prepare a lecture now.
indeed, that cannot work, because what you get is an empty object and
so accessing its coefficients will generate a segfault whatever
OtherDerived is (a Matrix or an expression). Even using .rows() on
this object will generate an invalid read (unless it is known at
compile time).
gael.