c++ – Eigen – get a matrix from a map?

c++ – Eigen – get a matrix from a map?

Just use operator=:

MatrixXd mat;
mat = Map<MatrixXd>(data, rows, cols);

I have encountered the same issue but vector is constant, then you have to do it following way as @ggael proposed,

Eigen::MatrixXd mat = Eigen::Map<const Eigen::MatrixXd>(x.data(), rows, cols);

where x can be either const Eigen::VectorXd x or const std::vector<double> or C type array.

c++ – Eigen – get a matrix from a map?

Leave a Reply

Your email address will not be published.