#include#include int main() { Eigen::MatrixXd m(3,3); std::cout << "Number of columns: " << m.cols() << std::endl; return 0; }
#includeThis code creates a 3x3 matrix using the Armadillo library and outputs the number of columns using the n_cols attribute. Both examples use external libraries (Eigen and Armadillo) to work with dense matrices but the package/library used depends on the choice of the programmer.#include int main() { arma::mat m = { {1.0, 2.0, 3.0}, {4.0, 5.0, 6.0}, {7.0, 8.0, 9.0} }; std::cout << "Number of columns: " << m.n_cols << std::endl; return 0; }