Re: [eigen] Permuted Matrix |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Permuted Matrix
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Tue, 20 Jul 2010 11:07:24 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=6dZsiamONUDtGN+XyiOEqy2SKGh9XGC1r6IpMp/qnf4=; b=UsXYtoqPka6sGFYKNntgx6BjAWdCvcTIy3z0TOjYvyspsvsHR9ZYFEBVDp87NvoXzD O0FQ+nf8m6PuD02yRRNxcKn/bqj0TYopqZML+BdjqXVFrz4HfeaoAelYR8Hd0Nb4TAKf 7cBAUAmoLHTWPZ9mduqxIGj4ncv9h14njnsBQ=
- 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:content-transfer-encoding; b=DfVizYIqywfAVGzro00fIZ3AYifstFh2mreBRjGLNPZ8SmjZA3rySIVFE0ITu3asAd RN+VJNpWlho6ljUyKqx7f9RdePXWDsjsL7QMuXvXuB+ORHlUAHVyXtT9FUl8PvfVb2Zs UUaMKBT7/iRCxgaqgssZoeG9qxOqFMUxMgHRI=
2010/7/20 Christoph Hertzberg <chtz@xxxxxxxxxxxxxxxxxxxxxxxx>:
> Christoph Hertzberg wrote:
>> template<class Derived>
>> void access_test(const MatrixBase<Derived>& m1) {
>> MatrixBase<Derived> m2 = m1;
>> m2 += m1;
>> }
>>
>> int main(void) {
>> Matrix3d A, B;
>> access_test(A*B);
>> }
>
> with Eigen2 this actually compiles, but (as it seems) gets stuck in some
> infinite loop ...
Just for the record --- these infinite loops are a known problem with
Eigen2 that's been fixed in Eigen3.
Explanations: rvalue-only expressions don't implement write methods
such as coeffRef, but in Eigen2, MatrixBase still defines them as
calling the method in the Derived class. Since the method isn't
actually reimplemented in the Derived class, it actually calls again
the method from MatrixBase, leading to infinite recursion.
This was fixed in Eigen3 by the introduction of the DenseCoeffsBase
class, which is specialized separately for lvalue and rvalue
expressions. So this kind of error is caught at compile time.
Also for the record --- your code above,
MatrixBase<Derived> m2 = m1;
is not going to work anyway since m2 is declared as MatrixBase i.e. as
an empty object. We have added some safeguards against constructing
bad MatrixBase objects but apparently we need some more. Maybe we
could actually make the copy constructor private?
Benoit
>
>
> --
> ----------------------------------------------
> Dipl.-Inf. Christoph Hertzberg
> Cartesium 0.051
> Universität Bremen
> Enrique-Schmidt-Straße 5
> 28359 Bremen
>
> Tel: (+49) 421-218-64252
> ----------------------------------------------
>
>
>