#includeint main() { arma::mat A = {{1, 2}, {3, 4}}; return 0; }
#includeint main() { arma::mat A = {{1, 2}, {3, 4}}; arma::submat B = A.submat(0, 0, 1, 1); // creates a 2x2 submatrix from A return 0; }
#includeIn these examples, the `arma` namespace is used to access the matrix and submatrix classes. Therefore, the package/library used is Armadillo.int main() { arma::mat A = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; arma::submat B = A.submat(0, 1, 1, 2); // creates a 2x2 submatrix from A double v = B(1, 0); // access the element at (1, 0) in the submatrix return 0; }