Использование типа Eigen внутри графа повышения

У меня есть некоторые проблемы с выравниванием Eigen при добавлении вершины к следующему графику:

#include <boost/graph/adjacency_list.hpp>
#include <Eigen/Eigen>

struct Vertex
{
   EIGEN_MAKE_ALIGNED_OPERATOR_NEW
   Eigen::Affine3d T; // Here is the Fixed-size vectorizable Eigen object
};


struct aligned_listS { };

namespace boost 
{
  template <class ValueType>
  struct container_gen<aligned_listS, ValueType> 
  {
    typedef std::list<ValueType, Eigen::aligned_allocator<ValueType> > type;
  };
}

typedef boost::adjacency_list< boost::listS, aligned_listS, boost::directedS, Vertex> MyGraph;

int main(int, char*[])
{
   Vertex v;

   MyGraph g;
   boost::add_vertex(v, g);

   return 0;
}

Во время выполнения у меня появляется следующее сообщение об ошибке:

 /usr/local/include/eigen3/Eigen/src/Core/DenseStorage.h:56: Eigen::internal::plain_array<T, Size, MatrixOrArrayOptions, 16>::plain_array() [with T = double, int Size = 16, 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.

Кажется, что либо аргумент шаблонаalign_listS не установлен в правильном месте, либо мой выровненный распределитель неправильно определен. Поэтому я ищу некоторые подсказки о том, как заставить этот выровненный распределитель работать правильно.

Вот полная трассировка gdb, если она может помочь:

#0  0xb7fdf1b2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
#1  0xb7d401df in __GI_raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#2  0xb7d43825 in __GI_abort () at abort.c:91
#3  0xb7d39085 in __assert_fail_base (fmt=0xb7e76c38 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
    assertion=0x804b324 "(reinterpret_cast<size_t>(array) & 0xf) == 0 && \"this assertion is explained here: \" \"http://eigen.tuxfamily.org/dox-devel/TopicUnalignedArrayAssert.html\" \" **** READ THIS WEB PAGE !!! ****\"", file=0x804b2ec "/usr/local/include/eigen3/Eigen/src/Core/DenseStorage.h", 
    line=56, 
    function=0x804b5e0 "Eigen::internal::plain_array<T, Size, MatrixOrArrayOptions, 16>::plain_array() [with T = double, int Size = 16, int MatrixOrArrayOptions = 0]") at assert.c:94
#4  0xb7d39137 in __GI___assert_fail (
    assertion=0x804b324 "(reinterpret_cast<size_t>(array) & 0xf) == 0 && \"this assertion is explained here: \" \"http://eigen.tuxfamily.org/dox-devel/TopicUnalignedArrayAssert.html\" \" **** READ THIS WEB PAGE !!! ****\"", file=0x804b2ec "/usr/local/include/eigen3/Eigen/src/Core/DenseStorage.h", 
    line=56, 
    function=0x804b5e0 "Eigen::internal::plain_array<T, Size, MatrixOrArrayOptions, 16>::plain_array() [with T = double, int Size = 16, int MatrixOrArrayOptions = 0]") at assert.c:103
#5  0x08049f1c in Eigen::internal::plain_array<double, 16, 0, 16>::plain_array() ()
#6  0x080499f1 in Eigen::DenseStorage<double, 16, 4, 4, 0>::DenseStorage() ()
#7  0x0804935a in Eigen::PlainObjectBase<Eigen::Matrix<double, 4, 4, 0, 4, 4> >::PlainObjectBase() ()
#8  0x08048ec7 in Eigen::Matrix<double, 4, 4, 0, 4, 4>::Matrix() ()
#9  0x08049d71 in Eigen::Transform<double, 3, 2, 0>::Transform(Eigen::Transform<double, 3, 2, 0> const&) ()
#10 0x080496c0 in Vertex::Vertex(Vertex const&) ()
#11 0x080496e9 in boost::detail::adj_list_gen<boost::adjacency_list<boost::listS, aligned_listS, boost::directedS, Vertex, boost::no_property, boost::no_property, boost::listS>, aligned_listS, boost::listS, boost::directedS, Vertex, boost::no_property, boost::no_property, boost::listS>::config::seq_stored_vertex::seq_stored_vertex(Vertex const&) ()
#12 0x080491cc in boost::detail::adj_list_gen<boost::adjacency_list<boost::listS, aligned_listS, boost::directedS, Vertex, boost::no_property, boost::no_property, boost::listS>, aligned_listS, boost::listS, boost::directedS, Vertex, boost::no_property, boost::no_property, boost::listS>::config::stored_vertex::stored_vertex(Vertex const&) ()
#13 0x08048df3 in boost::detail::adj_list_gen<boost::adjacency_list<boost::listS, aligned_listS, boost::directedS, Vertex, boost::no_property, boost::no_property, boost::listS>, aligned_listS, boost::listS, boost::directedS, Vertex, boost::no_property, boost::no_property, boost::listS>::config::vertex_descriptor boost::add_vertex<boost::adjacency_list<boost::listS, aligned_listS, boost::directedS, Vertex, boost::no_property, boost::no_property, boost::listS>, boost::detail::adj_list_gen<boost::adjacency_list<boost::listS, aligned_listS, boost::directedS, Vertex, boost::no_property, boost::no_property, boost::listS>, aligned_listS, boost::listS, boost::directedS, Vertex, boost::no_property, boost::no_property, boost::listS>::config, boost::directed_graph_helper<boost::detail::adj_list_gen<boost::adjacency_list<boost::listS, aligned_listS, boost::directedS, Vertex, boost::no_property, boost::no_property, boost::listS>, aligned_listS, boost::listS, boost::directedS, Vertex, boost::no_property, boost::no_property, boost::listS>::config> >(boost::detail::adj_list_gen<boost::adjacency_list<boost::listS, aligned_listS, boost::directedS, Vertex, boost::no_property, boost::no_property, boost::listS>, aligned_listS, boost::listS, boost::directedS, Vertex, boost::no_property, boost::no_property, boost::listS>::config::vertex_property_type const&, boost::adj_list_impl<boost::adjacency_list<boost::listS, aligned_listS, boost::directedS, Vertex, boost::no_property, boost::no_property, boost::listS>, boost::detail::adj_list_gen<boost::adjacency_list<boost::listS, aligned_listS, boost::directedS, Vertex, boost::no_property, boost::no_property, boost::listS>, aligned_listS, boost::listS, boost::directedS, Vertex, boost::no_property, boost::no_property, boost::listS>::config, boost::directed_graph_helper<boost::detail::adj_list_gen<boost::adjacency_list<boost::listS, aligned_listS, boost::directedS, Vertex, boost::no_property, boost::no_property, boost::listS>, aligned_listS, boost::listS, boost::directedS, Vertex, boost::no_property, boost::no_property, boost::listS>::config> >&) ()
#14 0x080489be in main ()

person A-M    schedule 07.05.2013    source источник
comment
Я не получаю эту ошибку. Какую версию компилятора и версию Eigen вы используете?   -  person David Brown    schedule 08.05.2013
comment
Я использую Ubuntu 12.04 и использую g++ (4.6.3), с Eigen 3.1.3 и boost 1.52.0. Для компиляции я использовал команду g++ graph.cpp -I/usr/local/include/eigen3 и никаких других флагов.   -  person A-M    schedule 08.05.2013
comment
РЕДАКТИРОВАТЬ: class Vertex -> struct Vertex, поскольку EIGEN_MAKE_ALIGNED_OPERATOR_NEW должен быть общедоступным.   -  person A-M    schedule 08.05.2013


Ответы (1)


Способ обойти это иметь следующее определение графа:

typedef boost::adjacency_list< boost::listS, boost::listS, boost::directedS, boost::shared_ptr<Vertex> > MyGraph;

И в этом случае этот код не генерирует утверждение.

   boost::shared_ptr<Vertex> ptr(new Vertex(v));
   boost::add_vertex(ptr, g);

В этом случае макрос Eigen, похоже, работает. Однако я до сих пор не понимаю, почему первый код не работает. Использование указателя - это скорее патч, чем решение...

person A-M    schedule 08.05.2013