Eigen extracting submatrix from vector of indices

While this was not possible at the time this question was asked, it has since been added in the development branch!

It's very straight forward:

Eigen::MatrixXf matrix;
Eigen::VectorXi columns;
Eigen::MatrixXf extracted_cols = matrix(Eigen::all, columns);

So I'm guessing this will be in the 3.3.5 3.4 stable release. Until then the development branch is the way to go.


Unfortunately, this is still not directly supported even in Eigen 3.3. There has been this feature request for a while: http://eigen.tuxfamily.org/bz/show_bug.cgi?id=329

Gael linked to an example implementation in one of the comments there: http://eigen.tuxfamily.org/dox-devel/TopicCustomizing_NullaryExpr.html#title1

Tags:

C++

Eigen