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?
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.
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.
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
-- GitLab Migration Automatic Message -- This bug has been migrated to gitlab.com'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: https://gitlab.com/libeigen/eigen/issues/1218.