Re: [eigen] About alignement: two use cases |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] About alignement: two use cases
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Tue, 1 Feb 2011 17:52:44 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type:content-transfer-encoding; bh=l6YA98k60/2CCQQPlwA1etPiHXTMQFIM2XpD/x01+ec=; b=RhbTlwo0TKzDfcmtRaxaMJwscQyIvxb3UL+02t/WStTU30KXomfw75G2aAS0NrnSvl Y23pIuwVFTcIAQKf/PWOg64a7TQJylPq1KW5tmXbZtAr+gc36lXFUgANIcMw7H7mkPBU np3eiJJTx8rhWEkYh3lkuOvcsutjAAAppILdQ=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=xnOA4LqWa3JfTUReJ6ywS3PrRoraBMB5miVDQqTnEX/WW3jtCCeXUwkjP+xa8k6rYT PWs5QEstaO4y6qY5MCBBGEIVH2SsS4zfuw0IqqFnYQ/Xd6CnkQOQUO/Qrxr682/Af5CB Wr1ytWDz1zEzFieCMxJmw5q6olo8fCXARrKtY=
Hi,
sorry for the delay,
On Tue, Jan 18, 2011 at 3:33 PM, <hamelin.philippe@xxxxxxx> wrote:
> USE CASE #1
> ===========================
>
> Let say I have a class looking like this:
>
> class A
> {
> public:
>
> Eigen::Vector6d v;
>
> EIGEN_MAKE_ALIGNED_OPERATOR_NEW
> };
>
> So far, I think this is the right way to do it. However, if another
> class derive from it:
>
> class B : public A
> {
> ...
> }
>
> Does the class B has also to use the EIGEN_MAMKE_ALIGNED_OPERATOR_NEW macro?
Unfortunately the answer is yes.
> USE CASE #2
> ===========================
>
> Let say I have a static library compiled with the EIGEN_DONT_ALIGN
> flash, which contains this class:
>
> class C
> {
> public:
>
> Eigen::Vector6d v;
> }
>
> Then, if I use this class from another program that is NOT compiled with
> EIGEN_DONT_ALIGN, e.g.:
>
> int main(void)
> {
> C* my_C = new C();
>
> Eigen::Vector6d my_v = my_C.v;
>
> return 0;
> }
The EIGEN_DONT_ALIGN flag breaks the ABI, so basically you should not
try to link a program compiled without this flags against a lib
compiled with it.
> In that case, the "v" member of class C is implicitly not aligned. However,
> the progam doesn't specify anything about alignement. Does this makes sense?
> Does the casting will be done correctly as in:
>
> Eigen::MAtrix<double, 6, 1, Eigen::DontAlign> v_unaligned;
> Eigen::MAtrix<double, 6, 1> v_aligned;
>
> v_aligned = v_unaligned;
The EIGEN_DONT_ALIGN flag does not work like that, in the sens that it
does not automagically transform all Matrix<> types to the equivalent
with the Eigen::DontAlign option.
btw, note that there also exist a EIGEN_DONT_ALIGN_STATICALLY flag
which only disable the alignment for static allocation (fixed size
objects).
gael
>
> Thank you,
>
> ------------------------------------
> Philippe Hamelin, ing. jr, M. Ing
> Chercheur / Researcher
>
> T: 450-652-8499 x2198
> F: 450-652-1316
>
> Expertise robotique et civil
> Institut de recherche d'Hydro-Québec (IREQ)
> 1740, boul. Lionel-Boulet
> Varennes (QC) J3X 1S1, Canada
>