Is it possible to append an Eigen vector to an another matrix without copying any data? Given matrix m
and vector b
I would like to modify matrix m
such that m = [m, b]
without copying data. Is that possible at all?
An example is:
#include <Eigen/Core>
using namespace Eigen;
int main()
{
MatrixXd m(2,2);
m << 0, 1, 2, 3;
VectorXd b(2);
b << 4, 5;
return 0;
}
I tried to work with ggael's wonderful reply to a related question . This questions asks how to create a new matrix without copying data, whilst I would like to modify an existing matrix. I could use conservativeResize
to append column b
to m
but only at the expense of allocating new memory. Does somebody kindly have any ideas how to proceed?