Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if Eigen Matrix is column major or row major?

Tags:

c++

eigen

I need to use the underlying arrays of several eigen matrices that could be RowMajor or ColumnMajor.

Is there any way to check which of the formats is used? (besides comparing the first column, with the first n elements of the row/column)

I found the isRowMajor as part of an Enum in the base class for Eigen, but I don't know how to access it from inside my code.

like image 446
XapaJIaMnu Avatar asked Jul 31 '14 12:07

XapaJIaMnu


1 Answers

The following works for me (EigenMatrixType is anything derived from Eigen::MatrixBase)

EigenMatrixType M(...);   
std::cout << "IsRowMajor?: " << M.IsRowMajor << std::endl;

(edit: It seems to work also with SparseMatrix, even if i cannot find the enum in the the SparseMatrixBase documentation)

like image 79
MagunRa Avatar answered Oct 03 '22 18:10

MagunRa