Re: [eigen] UnalignedArrayAssert...

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


2010/9/6 Matthias Pospiech <matthias.pospiech@xxxxxx>:
> I am lost with all the assert failures.
>
> I am using a 2x2 double matrix in such a class construct:
>
> #include <Core>
> USING_PART_OF_NAMESPACE_EIGEN
> typedef Matrix<double,2,2> MatrixABCD;
>
> class ABCDPrivate
> {
> public:
>   MatrixABCD matrix;
>
> public:
>  // necessary for EIGEN Libary
>  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
> };
>
> ABCD::ABCD()
>   : d(new ABCDPrivate)
> {
>   d->matrix.setIdentity();
> }
>
>
> this now seems to work.
>
> But then it fails here: ( Lens is derived public from ABCD)
> void Lens::setFocalLength(double focallength)
> {
>   m_FocalLength = focallength;
>
>   MatrixABCD matrix; <<--- failure
>   matrix << 1.0 , 0.0, -1.0/m_FocalLength   , 1.0;
>
>   setMatrix(matrix);
> }
>
> why?

The only reason that I can think of, which the above would fail, is if
the compiler has a bug making it do wrong assumptions about stack
alignment.

http://eigen.tuxfamily.org/dox/WrongStackAlignment.html

as explained there, this was a GCC / Windows bug fixed in GCC 4.5.

>
> also I am using the class ABCD in a std::vector do I need to take special
> care of that?

Yes:

http://eigen.tuxfamily.org/dox/StlContainers.html

>
> This class collection is part of a workshop (next week) on programming for
> physicists and I wanted to
> use a decent matrix class instead of a simple self written class (which
> would be much easier to use
> and understand).

If this is just for educational purposes and you don't want to be
annoyed by these issues, just #define EIGEN_DONT_ALIGN. In Eigen3, you
can do better yet: EIGEN_DONT_ALIGN_STATICALLY solves the problem
while retaining vectorization for dynamic-size objects.

Benoit

>
> Matthias
>
>
>



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/