This bugzilla service is closed. All entries have been migrated to
Bug 1218 - (Optionally) prohibit to assign row expressions to column vectors (and vice versa)
Summary: (Optionally) prohibit to assign row expressions to column vectors (and vice v...
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: 3.4 (development)
Hardware: All All
: Normal Internal Design
Assignee: Nobody
Keywords: Documentation
Depends on:
Blocks: 4.0 3.4
  Show dependency treegraph
Reported: 2016-05-05 15:52 UTC by Antonio Cervone
Modified: 2019-12-04 15:46 UTC (History)
3 users (show)


Description Antonio Cervone 2016-05-05 15:52:04 UTC
I discovered that the row() method return type can be implicitly converted to a column vector, as in this example

#include <iostream>

#include <Eigen/Dense>

int main()
  Eigen::Matrix<double,2,2> A;
  A << 1, 2, 3, 4;
  auto Arow = A.row(0);
  std::cout << Arow << std::endl;

  Eigen::Matrix<double,2,1> Acol = A.row(1);
  std::cout << Acol << std::endl;
  return 0;

I think that the second operation should give an error, and explicitly require a call to transpose() to work in this way.
Why is this happening? Is there any design here that I am not aware of?
Comment 1 Christoph Hertzberg 2016-05-05 18:58:19 UTC
Auto-transposing compile-time vectors was a very early design choice and disallowing it would unfortunately break the API.

We could introduce a compile-time-flag like EIGEN_DONT_AUTO_TRANSPOSE which, when defined, would result in an error for your code. And we can completely disallow it in a 4.0 release in the (far) future.

I thought we had a discussion/bug entry about that already, but I was not able to find it.
Comment 2 Antonio Cervone 2016-05-06 07:34:00 UTC
A compile time flag would do it for me, thanks.
A would also like to see this properly described in the docs, I could not find any reference to it.
Comment 3 Christoph Hertzberg 2019-08-14 12:10:51 UTC
I think the documentation of the current behavior should/could be done for 3.4. Changing the actual behavior depending on a compile-flag would also be possible already.

Only changing the default behavior should not be done before 4.0
Comment 4 Nobody 2019-12-04 15:46:51 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.