This bugzilla service is closed. All entries have been migrated to
Bug 1519 - Cannot construct a Vector/Matrix object from an indexed view of vector/matrix expressions such as VectorXd::Ones, MatrixXd::Identity
Summary: Cannot construct a Vector/Matrix object from an indexed view of vector/matrix...
Status: NEW
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: 3.4 (development)
Hardware: All All
: Normal Compilation Problem
Assignee: Nobody
Depends on:
Reported: 2018-02-12 11:35 UTC by Allan Leal
Modified: 2019-12-04 17:28 UTC (History)
4 users (show)


Description Allan Leal 2018-02-12 11:35:55 UTC
Consider the following code:

auto eye = MatrixXd::Identity(n, n);

auto subeye_view = eye(irows, icols); // this compiles

MatrixXd subeye_matrix = eye(irows, icols); // this DOES NOT compile

where `irows` and `icols` are some collection of indices.

Please allow VectorXx and MatrixXx objects to be constructed from indexed views of vector and matrix expressions such as VectorXd::Ones, VectorXd::Zero, MatrixXd::Identity, etc.
Comment 1 Allan Leal 2018-02-12 11:56:41 UTC
Further info. 

If the indices irows and icols are of type VectorXi, then the following can be seen in the output from g++:

Eigen/src/Core/CoreEvaluators.h:512:19: note: candidate template ignored: deduced conflicting types for parameter 'IndexType' ('int' vs. 'long')
  CoeffReturnType coeff(IndexType row, IndexType col) const

After this, I decided to change the integer type of the indices from int to long. By having irows and icols of type:

Eigen::Matrix<long, Eigen::Dynamic, 1>

this fixed the compilation error. 

Thus, something in Eigen needs to be changed to support other integer types, and not only long. Hopefully this is something simple to do.
Comment 2 Nobody 2019-12-04 17:28:45 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance:

Note You need to log in before you can comment on or make changes to this bug.