mysql录入foreigen错误_使用Eigen库遇到C2719错误的解决办法

Cause 1: Structures having Eigen objects as members

If you have code like this,

class Foo

{

//...

//...

};

//...

Foo *foo = new Foo;

then you need to read this separate page: Structures Having Eigen Members.

Note that here, Eigen::Vector2d is only used as an example, more generally the issue arises for all fixed-size vectorizable Eigen types.

Cause 2: STL Containers

If you use STL Containers such as std::vector, std::map, ..., with Eigen objects, or with classes containingEigen objects, like this,

std::vector<:matrix2f> my_vector;

struct my_class { ... Eigen::Matrix2f m; ... };

std::map my_map;

then you need to read this separate page: Using STL Containers with Eigen.

Cause 3: Passing Eigen objects by value

If some function in your code is getting an Eigen object passed by value, like this,

Note that here, Eigen::Vector4d is only used as an example, more generally the issue arises for all fixed-size vectorizable Eigen types.

Cause 4: Compiler making a wrong assumption on stack alignment (for instance GCC on Windows)

This is a must-read for people using GCC on Windows (like MinGW or TDM-GCC). If you have this assertion failure in an innocent function declaring a local variable like this:

void foo()

{

//...

}

Note that here, Eigen::Quaternionf is only used as an example, more generally the issue arises for all fixed-size vectorizable Eigen types.

Explanation

fixed-size vectorizable Eigen objects must absolutely be created at 16-byte-aligned locations, otherwise SIMD instructions adressing them will crash.

Eigen normally takes care of these alignment issues for you, by setting an alignment attribute on them and by overloading their "operator new".

However there are a few corner cases where these alignment settings get overridden: they are the possible causes for this assertion.

I don't care about vectorization, how do I get rid of that stuff?

Two possibilities: Define EIGEN_DONT_ALIGN_STATICALLY. That disables all 128-bit static alignment code, while keeping 128-bit heap alignment. This has the effect of disabling vectorization for fixed-size objects (like Matrix4d) while keeping vectorization of dynamic-size objects (like MatrixXd). But do note that this breaks ABI compatibility with the default behavior of 128-bit static alignment.

Or define both EIGEN_DONT_VECTORIZE and EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT. This keeps the 128-bit alignment code and thus preserves ABI compatibility, but completely disables vectorization.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值