Re: [eigen] Support for true Array

[ Thread Index | Date Index | More Archives ]

2009/11/25 Gael Guennebaud <gael.guennebaud@xxxxxxxxx>:
> actually Eigen already allows you to do either SoA or AoS. For instance,
> let's consider a list of Vector3f. To get the AoS behavior you'd do:
> Matrix<float,3,Dynamic,ColMajor> data;
> and for the SoA:
> Matrix<float,3,Dynamic,RowMajor> data;
> Unlike a vector of Vector3f, you have to access the element using .col(i),
> instead of [i].
> Then you can for instance normalize all vectors:
> data.colwise().normalize()
> If you opted for the SoA layout, this normalization will be vectorized
> (though there is still room for optimizations here).
> Note that all basics linear operations (+, -, scalar products) are
> automatically vectorized in both cases because in this case, Eigen will
> interpret such a matrix as a 3*size linear vector.
> Finallly, this SoA layout is still not optimal. A better option is to group
> the data per packet, e.g., for a 2D vector of floats you would do:
> x0, x1, x2, x3, y0, y1, y2, y3, x4, x5, x6, x6, y4, y5, y6, y7, ....
> but that one is more difficult to implement because it requires special
> cares.

Yes, so I agree with all you say, but the nice thing with the Array
class will be that it will work with the most natural syntax and
without special care at all (in particular without hardcoding a
specific packet size). That's pretty awesome!


Mail converted by MHonArc 2.6.19+