Registered Member
|
hello,
i have questions how to solve the issues of holding eigen objects in stl containers like std::vector< Vector4d >. first of all, i'm a bit confused. As described in the documentation [1], the issues arise just with fixed-size even Vector/Matrixes like Vector2d and 4d not with Vector3d or 5d (in the case of double)? but can i use a Vector4d in a list? or a queue? more generally, are all stl containers supported? now to the solutions: can i tell gcc to take care of the alignment? as fare as i experienced it, the problems arise on 32bit maschines (amd64 allocates always 16byte). am i right? 1) using aligned_allocator: define all std::containers with i.e: std::vector<Vector2d,aligned_allocator<Vector2d>> what if i have a Base class that uses a templated type. on construction, do I need to specify the object type AND the allocator type. is this possible? 2) EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix2d) this solution is just for std::vectors? for all other containers there is no such solution? if i have diffrent std::vectors with diffrent Matrizes, is this spezialization possible for all of them? 3) using DontAlign: as described in the topic [2], use self defined Eigen Matrizes i.e typedef Matrix<2,1, double, DontAlign> Vector2dDontAlign what is the drawback if i cant vectorize my Matrixes? is this a drawbak if i use this type just for my stl container and for nothing more? as fare as i know, the Vector2dDontAlign and Vector2d are compatible, so if i need vectorization, i just need to save it in an aligned type? thanks, peter [1] http://eigen.tuxfamily.org/dox-devel/TopicStlContainers.html [2] viewtopic.php?f=74&t=95992 |
Moderator
|
0) yes on 65 bits systems you are safe most of the time.
1) I don't really get it, but in your template class you can safely do: std::vector<VecType,Eigen::aligned_allocator<VecType> > 2) yes, I think they are only for std::vector 3) I'd probably go with Vector2dDontAlign, losing vectorization at some places is usually not critical. If you use one of these objects in an expensive computation, you can still first copy it into an aligned Vector2d. std::vector<Vector2dDontAlign> points; //... Vector2d p = points.at(i); // use p instead of points.at(i) |
Registered Member
|
thanks a lot for your answer! especially the hint with the template class is very useful.
|
Registered users: bartoloni, Bing [Bot], Google [Bot], Yahoo [Bot]