New user self-registration is disabled due to spam. Please email eigen-core-team @ lists.tuxfamily.org if you need an account.
Before reporting a bug, please make sure that your Eigen version is up-to-date!
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
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-12 11:35 UTC by Allan Leal
Modified: 2018-02-12 11:56 UTC (History)
4 users (show)



Attachments

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.

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