structeigenlemon-graph-library

Structures having fixed-size Eigen objects as member and containers


I have a structure with a fixed-size Eigen object as member that I want to use as an edge map with Lemon:

struct EdgeStatus
{
    Matrix<float,3,4> Data;
    …
    EIGEN_MAKE_ALIGNED_OPERATOR_NEW
};

ListGraph::EdgeMap<EdgeStatus> edgeMap(mygraph);

The code compiles fine, but I get a run-time error:

include/Eigen/src/Core/DenseStorage.h:56: Eigen::internal::plain_array<T, Size, MatrixOrArrayOptions, 16>::plain_array()
[with T = float, int Size = 12, int MatrixOrArrayOptions = 0]: Assertion `(reinterpret_cast<size_t>(array) & 0xf) == 0
&& "this assertion is explained here: " "http://eigen.tuxfamily.org/dox-devel/TopicUnalignedArrayAssert.html" " **** READ THIS WEB PAGE !!! ****"' failed.
Aborted

How should I solve this problem? (I have already included the EIGEN_MAKE_ALIGNED_OPERATOR_NEW macro.)


Solution

  • I don't know the LEMON library, but if ListGraph::EdgeMap allows you to specify an allocator, then you have to use our aligned_allocator.

    Otherwise you have to give up vectorization for your members as follow:

    struct EdgeStatus
    {
      Matrix<float,3,4, Eigen::DontAlign> Data;
      // ...
    };