Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 MATLAB 中,我可以执行以下操作
A = [1 2 3; 4 5 6]; A(:)
要得到:
ans = 1 4 2 5 3 6
我将如何使用 Eigen3 矩阵执行此操作?
最好的方法是使用地图:
Map<VectorXd> v(A.data(),A.size());
因为在这种情况下,Eigen 在编译时知道您现在有一个一维向量。
当然,结果将取决于 A 的存储顺序,即对于列主矩阵(默认):
[1 4 2 5 3 6]^T
对于行主要的:
[1 2 3 4 5 6]^T