|
|
(13 intermediate revisions by 3 users not shown) |
Line 1: |
Line 1: |
− | = Pit Falls =
| + | Moved there: http://eigen.tuxfamily.org/dox-devel/TopicPitfalls.html |
− | | + | |
− | == Alignment Issues (crash) ==
| + | |
− | Eigen has made some trade offs in favor of performance that have some costs in the use of the library.
| + | |
− | | + | |
− | Specifically there are a class of pit-falls related to alignment that are important to understand before choosing Eigen.
| + | |
− | | + | |
− | You can read more about them [http://eigen.tuxfamily.org/dox/UnalignedArrayAssert.html| here] but in short they are:
| + | |
− | | + | |
− | * [http://eigen.tuxfamily.org/dox/StructHavingEigenMembers.html| You cannot safely pass-by-value] (crash)
| + | |
− | * If you have members of classes that are Eigen types be sure to [http://eigen.tuxfamily.org/dox/StructHavingEigenMembers.html| use the included macro] that defines a new 'new' operator to fix alignment (crash)
| + | |
− | * Using Eigen types with STL containers [http://eigen.tuxfamily.org/dox/StlContainers.html| requires use of special allocators] (crash)
| + | |
− | ** This probably implies a whole class of issues that may result from using Eigen types with templates that allocate memory (''does anyone know if this is true'')
| + | |
− | * If you are using GCC on windows you must use [http://eigen.tuxfamily.org/dox/WrongStackAlignment.html| special considerations and fixes] to make it work (crash)
| + | |
− | | + | |
− | | + | |
− | | + | |
− | == Header Issues (failure to compile) ==
| + | |
− | Eigen has split the functionality of individual types across header files which can cause confusion. Just because you can instantiate a type does not mean that you have access to all of it's functionality. To concisely illustrate the issue consider the following:
| + | |
− | | + | |
− | #include <Eigen/Core>
| + | |
− | int main()
| + | |
− | {
| + | |
− | Eigen::Vector3d vec1, vec2;
| + | |
− | vec1.cross( vec2 );
| + | |
− | return 0;
| + | |
− | }
| + | |
− | | + | |
− | Compiling this will an error in line 5 (''vec1.cross...''):
| + | |
− | undefined reference to `Eigen::Matrix<double, 3, 1, 2, 3, 1> Eigen::MatrixBase<Eigen::Matrix<double, 3, 1, 2, 3, 1> >::cross<Eigen::Matrix<double, 3, 1, 2, 3, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, 3, 1, 2, 3, 1> > const&) const'
| + | |
− | ...because the cross product functionality is in another header(Eigen/Geometry).
| + | |