New user self-registration is disabled due to spam. Please email eigen-core-team @ if you need an account.
Before reporting a bug, please make sure that your Eigen version is up-to-date!

Bug 1218

Summary: (Optionally) prohibit to assign row expressions to column vectors (and vice versa)
Product: Eigen Reporter: Antonio Cervone <ant.cervone>
Component: Core - generalAssignee: Nobody <eigen.nobody>
Status: DECISIONNEEDED ---    
Severity: Internal Design CC: chtz, gael.guennebaud, jacob.benoit.1
Priority: Normal Keywords: Documentation
Version: 3.4 (development)   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 331, 814    

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