https://eigen.tuxfamily.org/dox-devel/group__TutorialReshape.html
注意,需要Eigen3.4版本
Since the version 3.4, Eigen exposes convenient methods to reshape a matrix to another matrix of different sizes or vector. All cases are handled via the DenseBase::reshaped(NRowsType,NColsType) and DenseBase::reshaped() functions. Those functions do not perform in-place reshaping, but instead return a view on the input expression.
Reshaped 2D views 2维矩阵的重排
The more general reshaping transformation is handled via: reshaped(nrows,ncols). Here is an example reshaping a 4x4 matrix to a 2x8 one:
例子1
code:注意,默认是列优先,matlab的reshape是列优先
Matrix4i m = Matrix4i::Random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is m.reshaped(2, 8):" <&l