2008-12-08 00:31:32 +08:00
namespace Eigen {
/** \page UnalignedArrayAssert Explanation of the assertion on unaligned arrays
2009-01-12 22:41:12 +08:00
Hello! You are seeing this webpage because your program terminated on an assertion failure like this one:
<pre>
my_program: path/to/eigen2/Eigen/src/Core/MatrixStorage.h:44:
Eigen::ei_matrix_array<T, Size, MatrixOptions, Align>::ei_matrix_array()
[with T = double, int Size = 2, int MatrixOptions = 2, bool Align = true]:
Assertion `(reinterpret_cast<size_t>(array) & 0xf) == 0 && "this assertion
is explained here: http://eigen.tuxfamily.org/api/UnalignedArrayAssert.html
**** READ THIS WEB PAGE !!! ****"' failed.
</pre>
There are 3 known causes for this issue. Please read on to understand them and learn how to fix them.
2008-12-08 00:31:32 +08:00
2009-01-12 22:41:12 +08:00
\b Table \b of \b contents
- \ref c1
- \ref c2
- \ref c3
- \ref explanation
2008-12-08 00:31:32 +08:00
2009-01-12 22:41:12 +08:00
\section c1 Cause 1: Structures having Eigen objects as members
2008-12-08 00:31:32 +08:00
2009-01-12 22:41:12 +08:00
If you have code like this,
2008-12-08 00:31:32 +08:00
\code
2009-01-06 02:21:44 +08:00
class Foo
2008-12-08 00:31:32 +08:00
{
2009-01-12 22:41:12 +08:00
//...
2008-12-08 00:31:32 +08:00
Eigen::Vector2d v;
2009-01-12 22:41:12 +08:00
//...
2008-12-08 00:31:32 +08:00
};
2009-01-12 22:41:12 +08:00
//...
2008-12-08 00:31:32 +08:00
Foo *foo = new Foo;
\endcode
2009-01-12 22:41:12 +08:00
then you need to read this separate page: \ref StructHavingEigenMembers "Structures Having Eigen Members".
2009-01-06 11:16:50 +08:00
2009-01-12 22:41:12 +08:00
Note that here, Eigen::Vector2d is only used as an example, more generally the issue arises for all \ref FixedSizeVectorizable "fixed-size vectorizable Eigen types".
2009-01-06 11:16:50 +08:00
2009-01-12 22:41:12 +08:00
\section c2 Cause 2: STL Containers
2009-01-06 11:16:50 +08:00
2009-01-12 22:41:12 +08:00
If you use STL Containers such as std::vector, std::map, ..., with Eigen objects, like this,
2009-01-06 11:16:50 +08:00
\code
2009-01-12 22:41:12 +08:00
std::vector<Eigen::Matrix2f> my_vector;
std::map<int, Eigen::Matrix2f> my_map;
2009-01-06 11:16:50 +08:00
\endcode
2009-01-12 22:41:12 +08:00
then you need to read this separate page: \ref StlContainers "Using STL Containers with Eigen".
2009-01-06 11:16:50 +08:00
2009-01-12 22:41:12 +08:00
Note that here, Eigen::Matrix2f is only used as an example, more generally the issue arises for all \ref FixedSizeVectorizable "fixed-size vectorizable Eigen types".
2009-01-06 11:16:50 +08:00
2009-01-12 22:41:12 +08:00
\section c3 Cause 3: Passing Eigen objects by value
2008-12-08 00:31:32 +08:00
2009-01-12 22:41:12 +08:00
If some function in your code is getting an Eigen object passed by value, like this,
2008-12-08 00:31:32 +08:00
\code
2009-01-12 22:41:12 +08:00
void func(Eigen::Vector4d v);
2008-12-08 00:31:32 +08:00
\endcode
2009-01-12 22:41:12 +08:00
then you need to read this separate page: \ref PassingByValue "Passing Eigen objects by value to functions".
2008-12-08 00:31:32 +08:00
2009-01-12 22:41:12 +08:00
Note that here, Eigen::Vector4d is only used as an example, more generally the issue arises for all \ref FixedSizeVectorizable "fixed-size vectorizable Eigen types".
2008-12-08 00:31:32 +08:00
2009-01-12 22:41:12 +08:00
\section explanation General explanation of this assertion
2008-12-08 00:31:32 +08:00
2009-01-12 22:41:12 +08:00
\ref FixedSizeVectorizable "fixed-size vectorizable Eigen objects" must absolutely be created at 16-byte-aligned locations, otherwise SIMD instructions adressing them will crash.
2008-12-08 00:31:32 +08:00
2009-01-12 22:41:12 +08:00
Eigen normally takes care of these alignment issues for you, by setting an alignment attribute on them and by overloading their "operator new".
2009-01-06 11:16:50 +08:00
2009-01-12 22:41:12 +08:00
However there are a few corner cases where these alignment settings get overridden: they are the possible causes for this assertion.
2009-01-06 11:16:50 +08:00
2008-12-08 00:31:32 +08:00
*/
}