Example code: ``` #include <Eigen/Dense> void test() { const int rows = 3; const int cols1 = 1; const int cols2 = 0; // If changed to cols2 != 0, works fine Eigen::MatrixXd A1(rows, cols1); Eigen::MatrixXd A2(rows, cols2); Eigen::MatrixXd B(rows, cols1+cols2); B << A1, A2; } ``` Produces the following assertion at runtime: ``` Assertion failed: m_row+m_currentBlockRows<=m_xpr.rows() && "Too many rows passe d to comma initializer (operator<<)", file v:\002\source\3rdparty\eigen\eigen-3. 3-beta2\include\eigen\src/Core/CommaInitializer.h, line 94 ``` I expected be the code to work find and B to be equal to A1. I know, that this is a nasty corner case... not introduced by me, but used in a library I want to use. This issue may be strongly related to #1242, which had a similar problem with rows instead of columns.
I fixed it here: https://bitbucket.org/eigen/eigen/commits/4df84dee97d2f3eaeb The only remaining border case are things like MatrixXd B(4,0); B << MatrixXd(2,0), MatrixXd(2,0); Here it is not clear immediately, if the second block is part of the first two rows or shall start the next rows. Solving more complicated variations of that would require some sort of backtracking which I think is not worth the effort. Alternatively, we could disable the assertion in the destructor if the total size is zero.
Puh... I also think, that backtracking in such cases is not required. Disabling the assertion for matrices with zero size sounds like a good idea to me, but you are the expert! Anyway, thanks for the fix :)
I decided to disable the "Too few coefficients" assertion for the cols==0 case, and I moved the assertion into the "finished()" method: https://bitbucket.org/eigen/eigen/commits/be75b8ad7d1e9 I also backported the changes to the 3.2 branch: https://bitbucket.org/eigen/eigen/commits/435ba1a184931 https://bitbucket.org/eigen/eigen/commits/10f2cc514f6ca
*** Bug 1280 has been marked as a duplicate of this bug. ***
-- GitLab Migration Automatic Message -- This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/1272.