I have an eigen Matrix A
which has 4 rows & 2 columns. Also I have two eigen Matrices B
and C
both have 2 rows and 2 columns. I want to add that two Matrices one after other into my Matrix A
. In order to do that one I used the following code which is apparently not correct. Any help is appreciated. Thank you.
MatrixXd A(4,4);
MatrixXd B(2,2);
MatrixXd C(2,2);
B << 1,2,
3,4;
C << 5,6,
7,8;
A << B, // Error message:
C;
Error message:
XprType& Eigen::CommaInitializer<MatrixType>::finished() [with XprType = Eigen::Matrix<double, -1, -1>]: Assertion `((m_row+m_currentBlockRows) == m_xpr.rows() || m_xpr.cols() == 0) && m_col == m_xpr.cols() && "Too few coefficients passed to comma initializer (operator<<)"' failed.
Required output:( 4 rows, 2 columns)
A = 1, 2,
3, 4,
5,6,
7,8;