Difference between revisions of "Pit Falls"

From Eigen
Jump to: navigation, search
(Alignment Issues (crash))
(Replaced content with "Moved there: http://eigen.tuxfamily.org/dox-devel/TopicPitfalls.html")
 
(12 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 (runtime assertion) ==
+
 
+
Eigen does explicit vectorization, and while that is appreciated by many users, that also leads to some issues in special situations where data alignment is compromised. Indeed, C++98 doesn't have quite good enough support for explicit data alignment (that's coming in C++1x). In that case your program hits an assertion failure (that is, a "controlled crash") with a message that tells you to consult this page:
+
 
+
  [http://eigen.tuxfamily.org/dox/UnalignedArrayAssert.html http://eigen.tuxfamily.org/dox/UnalignedArrayAssert.html]
+
 
+
Have a look at it and see for yourself if that's something that can cope with. It contains detailed information about how to deal with each known cause for that issue.
+
 
+
Now what if you don't care about vectorization and so don't want to be annoyed with these alignment issues? The easiest is that you define these two preprocessor symbols: EIGEN_DONT_VECTORIZE and EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT. If you use the development branch, it's even easier, just define EIGEN_DONT_ALIGN.
+
 
+
== 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).
+

Latest revision as of 12:26, 30 January 2019

Moved there: http://eigen.tuxfamily.org/dox-devel/TopicPitfalls.html