#includeint main() { // Creating a 3x3 matrix arma::mat A = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; // Creating a 3-element vector arma::vec b = {1, 2, 3}; return 0; }
#includeint main() { // Creating two matrices arma::mat A = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; arma::mat B = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}; // Multiplying the two matrices arma::mat C = A * B; return 0; }
#includeIn these examples, we used the C++ Armadillo package, which is a library for performing linear algebra operations.int main() { // Creating a coefficient matrix and a right-hand side vector arma::mat A = {{2, 1}, {1, 3}}; arma::vec b = {1, 2}; // Solving the linear system Ax = b for the unknown vector x arma::vec x = arma::solve(A, b); return 0; }