Re: [eigen] Rigid Transformations in eigen: discussion thread

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


On Thu, Sep 17, 2009 at 10:12 PM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
> 2009/9/17 Benoit Jacob <jacob.benoit.1@xxxxxxxxx>:
>> Here's  a little idea to make it more easy for the user to do his own
>> operations like sum.
>
> Oh, I just thought about something better, with fewer changes:
>
> Since your 2 quats are an array, you know they're adjacent in memory,
> so you can just make the coeffs() method reinterpret_cast the address
> of the first quat!
>
> So you keep the same data members that you currently have, and add this method:
>
> Vector8Type &coeffs()
> {
>  return *reinterpret_cast<Vector8Type*>(&m_quats[0]);
> }
>
> Actually you could also do this with a Map<Vector8Type> but 1) you'd
> have to do ForceAligned or something like that to tell him that the
> ptr is aligned, i don't remember exactly how that works, and 2) that
> would be just more complicated code for the same thing.
>
> Notice that this reinterpret_cast trick only works with fixed-size
> objects! If you had dynamic size objects, the Map<...> would be the
> only way to do that.
>
> Also here we're assuming that quaternions and vector8's have the same
> alignment requirements. That's currently always true. It'll be false
> in the future if a platform has 256 bit packets.

If you are talking about AVX, then AFAIK, it won't need 32 byte
alignment. It'll happily work with 16 byte aligned pointers.
>
> Benoit
>
>
>



-- 
Rohit Garg

http://rpg-314.blogspot.com/

Senior Undergraduate
Department of Physics
Indian Institute of Technology
Bombay



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