1 | 赋值 | Eigen::MatrixXf mat (12,1); \\% mat << 1, 2, 3, 4,5,6,7,8,9,10,11,12; |
2 | Inplace操作 \\% resize | mat.resize(4, 3); \\% 1 5 9 \\% 2 6 10 \\% 3 7 11 \\% 4 8 12 |
3 | 转置 \\% transposeInPlace | mat.transposeInPlace(); \\% 1 2 3 4 \\% 5 6 7 8 \\% 9 10 11 12 |
4 | 切片 | mat.block(1,2,2,2) \\% 7 8 \\% 11 12 \\% mat.leftCols(2) \\% 1 2 \\% 5 6 \\% 9 10 \\% mat.middleCols(1,2) \\% 2 3 \\% 6 7 \\% 10 11 \\% mat.rightCols(2) \\% 3 4 \\% 7 8 \\% 11 12 |
5 | c++array类型 \\% 转eigen数组 | int arr[12] = { 1, 2, 3, 4,5,6,7,8,9,10,11,12 }; \\% Eigen::MatrixXi mat(12, 1); \\% mat = Eigen::Map<Eigen::MatrixXi>(arr,12,1); |
6 | eigen类型转换 | Eigen::MatrixXf matF(12, 1); \\% matF=mat.cast<float>(); |