使用一个特征类型内提升图
Using a Eigen type inside boost graph
我有一些特征对齐问题时,添加一个顶点到以下图:
#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.
似乎aligned_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 ()
一种解决方法是使用以下图形定义:
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宏似乎可以完成任务。然而,我仍然不明白为什么第一个代码没有运行。使用指针更像是一个补丁而不是解决方案…
相关文章:
- 根据C++标准的定义实现"is_similar"类型特征
- C++类型特征,以查看是否可以<uint32_t>对类型"K"的任何变量调用"static_cast(k)"
- C ++类型特征:确保子类实现方法
- 根据类型特征更改函数定义?
- 如何使用类型特征将函数的通用引用参数限制为 r 值引用?
- 在C++中创建新的类型特征
- 如何构造一个类型特征,可以判断一个类型的私有方法是否可以在另一个类型的构造函数中调用?
- std::begin-类型特征中未考虑用户定义的重载
- 在类型特征修改后,无法限定类型
- 使用类型特征的部分类专用化
- 为什么不调用预期的函数?我是否对类型特征的理解不正确?
- 了解类型特征的体系结构
- 为什么使用某些类型特征的模板类型会导致模板扣除失败
- 有了C++类型特征,有没有办法避免铸造
- 哪种类型特征表明该类型是可分配的?(元组,对)
- 一种类型特征,标识哪个类提供通过重载解析选择的函数
- 如何使用类型特征正确推断引用的参数
- 如何通过扩展以下类型特征来删除 decltype(&MyClass::funct) 部分?
- 从标准库类型特征继承
- 为什么类型特征不适用于命名空间范围内的类型?