Obtenez la forme de la matrice eigen

#include <iostream>
#include <sstream> // <-- Added
#include "Eigen/Dense"

using std::cout;
using std::endl;
using std::string;
using std::ostringstream; // <-- Added
using Eigen::MatrixXd;
using Eigen::EigenBase;   // <-- Added

template <typename Derived>
std::string get_shape(const EigenBase<Derived>& x)
{
    std::ostringstream oss;
    oss  << "(" << x.rows() << ", " << x.cols() << ")";
    return oss.str();
}

int main(int argc, char**argv)
{
    MatrixXd m(2, 3);
    m << 1, 2, 3, 10, 20, 30;

    cout << "shape: " << get_shape(m) << endl;
    // shape: (2, 3)

    return 0;
}
Gill Bates