我有两个特征矩阵,我想将它们连接起来,就像在matlab cat(0, A, B)
中
Eigen 中是否有等同的东西?
谢谢。
最佳答案
您可以为此使用逗号初始化程序语法。
水平:
MatrixXd C(A.rows(), A.cols()+B.cols());
C << A, B;
垂直:
// eigen uses provided dimensions in declaration to determine
// concatenation direction
MatrixXd D(A.rows()+B.rows(), A.cols()); // <-- D(A.rows() + B.rows(), ...)
D << A, B; // <-- syntax is the same for vertical and horizontal concatenation
为了提高可读性,可以使用空格格式化垂直串联:
D << A,
B; // <-- But this is for readability only.
关于c++ - 特征值如何沿特定维度连接矩阵?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21496157/