Re: [eigen] Clang issue on MacOS when the set variable is used in the given data |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen <eigen@xxxxxxxxxxxxxxxxxxx>
- Subject: Re: [eigen] Clang issue on MacOS when the set variable is used in the given data
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Fri, 19 Apr 2013 13:14:38 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:content-type:content-transfer-encoding; bh=iRQwQtBFq8JpLmT4D4voT0Gf9hAY5sPvckacCL9oGbw=; b=vy/DrhgCN6buhZh231sgEsHQchc77RZOk9tEsifBEQC3nJ79Eowi00tcxFliA33YoL s2mvlZpKVi5mYcxeL6NLWSiQuj23pJYzYyR1Og8S2SmCDYIZG/n+EfFcA/YIEQNdYBMi YjAnriJOhDHSTlJpV0bPBRC8OKcv712TEFwCLANyoKgDP2MBOBAeJYyJSz9aCjkab1aU uKzx990Y528hI0RE6nUYSCU49+1vj/q9Eu91l+WiqosdolC+BHjM4yUA/w3azRGtZYxB kegfxJ3k8DDZSZLMcIKqToxTLsigViWmDf9R4DtmDQ/TFKOeHtQFlEVKSF0HZV6xxgT+ m6Kw==
On Fri, Apr 19, 2013 at 12:53 PM, Christoph Hertzberg
<chtz@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> On 19.04.2013 12:05, Gael Guennebaud wrote:
>>
>> Your second version should be ok because you do not read foo(0) after
>> it has been changed, but that's still a dangerous use.
>
>
> Does Eigen give any guarantees on how comma-initialization is performed?.
> I always assumed that
> foo << A, B, C;
> is basically the same as
> foo.segment<dim_A>(0 ) = A;
> foo.segment<dim_B>(dim_A ) = B;
> foo.segment<dim_C>(dim_A+dim_B) = C;
yes, in theory it's what happen in that order. but in that case
Arnaud's 1st example should fail regardless on the compiler. So there
might a c++ subtlety I'm missing.
gael
> E.g., generally it would make sense to evaluate the result of
> rot*foo.block(...) directly into the corresponding position of foo. That
> quite certainly can lead to aliasing issues (but does not have to for small
> matrices).
>
>> On Thu, Apr 18, 2013 at 8:58 AM, Arnaud BARRE <arnaud.barre@xxxxxxxxx>
>> wrote:
>>>
>>> For example, I have the following code:
>>> Eigen::Matrix<double,4,1> foo;
>>> foo << I, 1.0;
>>> foo << 0.0, rot * (inv * foo).block(1,0,2,1), 1.0;
>>> *JC = (local * foo).block(0,0,3,1);
>
>
> What I don't understand here, is why you need to use foo for two different
> temporaries? You can hardly be that short of memory.
> Furthermore, what is inv? If it was a Eigen::Transform, you can directly
> multiply by a 3d vector (no need to explicitly construct [I, 1.0]).
>
> Assuming local is a Transform as well:
> Eigen::Vector3d foo;
> foo << 0, rot * (inv * I).tail<2>();
> *JC = local * foo;
>
> And if inv does not fit into a Transform, you can use I.homogeneous()
> instead of (foo << I, 1.0);
>
>
> Christoph
>
> --
> ----------------------------------------------
> Dipl.-Inf., Dipl.-Math. Christoph Hertzberg
> Cartesium 0.049
> Universität Bremen
> Enrique-Schmidt-Straße 5
> 28359 Bremen
>
> Tel: +49 (421) 218-64252
> ----------------------------------------------
>
>