Search code examples
c++c++11c++14eigeneigen3

How to create dynamic sized Eigen::Matrix of double RowMajor?


Its said to use dynamic size to perform bigger https://eigen.tuxfamily.org/dox/group__TutorialMatrixClass.html, how to create it for RowMajor?

I have this (which I guess is fixed size ?)

Matrix<double, N, N, RowMajor> m;

I think for (default) ColMajor answer will be MatrixXd m(N,N);. What about RowMajor?

Where const int N = 1000;


Solution

  • Matrix<double, N, N, RowMajor> m; will create a RowMajor matrix of a fixed size (NxN, assuming N is known at runtime). If you want it to be dynamically sized, use Matrix<double, Dynamic, Dynamic, RowMajor> m; instead.