Re: [eigen] STL Vectors and Alignment
• To: eigen@xxxxxxxxxxxxxxxxxxx
• Subject: Re: [eigen] STL Vectors and Alignment
• From: Gabriel <gnuetzi@xxxxxxxxx>
• Date: Wed, 26 Nov 2014 16:17:14 +0100
• Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=/0FeeB8tqGxgynrkbSZrE35dsx2nwLuu7KynSQjy29Y=; b=b0Vrje0OtwgDgEDLGn/HY9lkSPNOS+vYUxtHiEL7fbn4PGWsysSodw8dNp39dTWsgz Ng493wMvDxvC9dmHwa+YprfEZrs3n7fzuPaDZBqkq6pYaGZ/IJGNHrQbVyfbUa+v2TZz 5o5f6EptGx4WxeCL/bk3pGU5F1lokZQHttFKIcWIhm1A0kmvciSA/ic5y46MTQ1wyW35 +LJ9FDMeJHrILZfuLECZVi/UEH+DAPZVmTmFyXASo5VwSgnbc6xaKXRipdzo3BDikcWg WsNpaBsdRDNN0n3Ber5IV8TYqfyHf13qF3p2kueMnq8mM9g1PFjyfGrLv4XTAGRoz4oA QGEA==

So that means if we have a class S with a hierarchy of classes composed in each other and
```the last one uses a fixed-size vectorizable type, for example

struct C{
B a;
};
struct B{
EIGEN_MAKE_ALIGNED_OPERATOR_NEW  // <  IS THIS NEEDED? not really
A a;
};
struct A{
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
Eigen::Vector2d a;
};

and we want to use S in an std::vector<S>

We need  :
#include<Eigen/StdVector>
std::vector<S, Eigen::aligned_allocator<S> >;

Is that correct? Isnt that really cumbersome? hm....

Thanks a lot!
Gabriel

On 11/26/2014 03:08 PM, Christoph Hertzberg wrote:
```
```For C++03 you need to

#include<Eigen/StdVector>

and then use

std::vector<A, Eigen::aligned_allocator<A> >;

It is explained here:
http://eigen.tuxfamily.org/dox/group__TopicStlContainers.html

Btw, the non-HTML part of your mail is slightly broken.

Cheers,
Christoph

On 26.11.2014 13:48, Gabriel wrote:
```
```
*Dear all**,*

Through the documentation which is awesomely cool :-)
I could not figure out the following cases:

*First Case: *

*struct A{**
**    Eigen::Vector2d a;**
**};**
**
**std::vector<A> vec;*

THIS is obviously wrong because there are alignement issues, described
on the page.
Is it enough to fix it like this:

*struct A{**
******EIGEN_MAKE_ALIGNED_OPERATOR_NEW**
**    Vector2d a;**
****
**};**
**std::vector<A> vec;*

Or is this going to fail alignment too*and I need something like this:*
*std::vector<  A  ,   Eigen::aligned_allocator<  A > >*

*Second Case: *

*struct B{**
**    A a;**
**};*
*struct A{*
**    EIGEN_MAKE_ALIGNED_OPERATOR_NEW**
* **    Eigen::Vector2d a;**
**};**
**
**std::vector<B> vec;*

Or is this going to fail alignment too*and I need something like this:*
*std::vector< B  ,   Eigen::aligned_allocator<  B > >*

Thanks a lot for the quick reply =)!
Gabriel

```
```

```
```

```

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