[eigen] Alignment

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

Hi all,

I started using Eigen2 for a research project a few days ago and found
it generally quite impressive. I particularly like the type safety of
fixed-size matrix operations. So, thanks for sharing Eigen2 with the
rest of the world :)

There's one thing I'm having trouble getting my head around though:

  What do I need to do to ensure vectorization-compatible alignment of
  Eigen datatypes contained in my own classes/structs if I need to
  store those in both std::vector and boost::array containers?

I've tried to follow the suggestions from the Eigen2 documentation [0]
but that doesn't seem to fully cover my use case which roughly boils
down to the following code snippet:

class foo
    // numerous Eigen::Matrix members. e.g.:
    Matrix<double, 4, 4> A;
    Vector3d v;


    // various member functions operating on foo
    // ...

int main()
    std::vector<foo, Eigen::aligned_allocator<foo> > foo_vector;

    // do stuff with foo_vector[i] 

    boost::array<foo, 20> foo_array;

    // do stuff with foo_array[i]

    return 0;

My understanding is that the std::vector variant should be safe unless
resize() is called.

What about boost::array? Given that it's a thin wrapper around a plain
array (see [1]) is the compiler guaranteed to figure out how to lay
things out in memory correctly?

Thanks in advance for any suggestions.



[0] http://eigen.tuxfamily.org/dox/UnalignedArrayAssert.html
[1] http://www.boost.org/doc/libs/1_37_0/doc/html/array.html

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