Registered Member
|
I have problem with instantiating the dynamic DiagonalMatrix object in my MSVS 12 project.
One of my classes has the member of type DiagonalMatrix* which is instantiated in the class constructor as follows: class QI_MatrixBlock : public QI_BaseBlock() { public: Eigen::DiagonalMatrix<std::complex<double>,Eigen::Dynamic,Eigen::RowMajor>* data; ... QI_MatrixBlock(size_t n):QI_BaseBlock() { ... //problem line! data=new Eigen::DiagonalMatrix<std::complex<double>,Eigen::Dynamic,Eigen::RowMajor>(n); }; ... } Execution of the problem line _sometimes_ raises the assertion on unaligned arrays: Assertion `(reinterpret_cast<size_t>(array) & 0xf) == 0 && "this assertion is explained here: http://eigen.tuxfamily.org/dox/Unaligne ... ssert.html READ THIS WEB PAGE !!! ****"' failed. By "sometimes" I mean that adding\removing random lines of code removes\recreates the assertion, probably because of overall changes in the objects' alignment. I checked the assertion explanation page http://eigen.tuxfamily.org/dox-devel/gr ... ssert.html but it seems that none of the typical causes match my case. Adding the line EIGEN_MAKE_ALIGNED_OPERATOR_NEW in the beginning of the class has no effect. Declarations: #define EIGEN_DONT_VECTORIZE #define EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT allow to pass the problem line but cause the program crash after execution of few next lines (which have no Eigen code). At the same time, everything goes smoothly if the DiagonalMatrix is replaced with dense matrix. Can you, please, help me to understand the origin of the problem and its solution? |
Moderator
|
The problem is that the third template argument of DiagonalMatrix is not the storage order (there is no storage order for a diagonal matrix), but the maximum diagonal size at compile time. Since RowMajor==1, this mean that your type is like a 1x1 matrix... Remove this third parameter to get the default and expected behavior.
|
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]