user3294195 - 1 year ago 129

C++ Question

If I want to concatenate two matrices

`A`

`B`

`using Eigen::MatrixXd;`

const MatrixXd A(n, p);

const MatrixXd B(n, q);

MatrixXd X(n, p+q);

X << A, B;

Now if

`n`

`p`

`q`

`X`

`A`

`B`

`X`

`Eigen::Ref<MatrixXd>`

Thanks.

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

No, `Ref`

is not designed for that. We/You would need to define a new expression for that, that could be called `Cat`

. If you only need to concatenate two matrices horizontally, in Eigen 3.3, this can be implemented in less than a dozen of lines of code as a nullary expression, see some exemple there.