#includeint main() { Eigen::MatrixXd A(4,4); A << 1,2,3,4, 5,6,7,8, 9,10,11,12, 13,14,15,16; Eigen::MatrixXd B = A.block(0,0,2,2); // Returns a submatrix of A std::cout << B << std::endl; return 0; }
#includeThis example creates the same 4x4 matrix `A`, but extracts the 2x2 submatrix starting at the entry in the second row and third column. The resulting submatrix `B` is printed to the console. Package Library: Eigen.int main() { Eigen::MatrixXd A(4,4); A << 1,2,3,4, 5,6,7,8, 9,10,11,12, 13,14,15,16; Eigen::MatrixXd B = A.block(1,2,2,2); // Returns a submatrix of A std::cout << B << std::endl; return 0; }