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 1218 - row() method returns a column
Summary: row() method returns a column
Status: DECISIONNEEDED
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: 3.4 (development)
Hardware: All All
: Normal Internal Design
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 4.0
  Show dependency treegraph
 
Reported: 2016-05-05 15:52 UTC by Antonio Cervone
Modified: 2016-05-06 07:34 UTC (History)
3 users (show)



Attachments

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.

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