#includeint main() { Eigen::Matrix3f m; //3x3 floating point matrix m << 1, 2, 3, 4, 5, 6, 7, 8, 9; std::cout << m << std::endl; return 0; }
#includeThis code creates two 2x2 matrices and multiplies them, producing another 2x2 matrix which is output to the console. Eigen is an open source C++ library for linear algebra operations on matrices and vectors.int main() { Eigen::MatrixXd A(2,2); //2x2 matrix Eigen::MatrixXd B(2,2); //2x2 matrix A << 1, 2, 3, 4; B << 5, 6, 7, 8; Eigen::MatrixXd C = A * B; std::cout << C << std::endl; return 0; }