#include#include int main() { // create a matrix with 3 rows and 5 columns arma::mat A = {{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}}; // get the number of columns int ncols = A.n_cols; std::cout << "Number of columns: " << ncols << std::endl; return 0; }
Number of columns: 5
#include#include int main() { // create a matrix with 4 rows and 3 columns Eigen::MatrixXd A(4, 3); A << 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12; // get the number of columns int ncols = A.cols(); std::cout << "Number of columns: " << ncols << std::endl; return 0; }
Number of columns: 3