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 ]


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
> ----------------------------------------------
>
>



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/