I'm coming over from Python & Numpy to C++ & Eigen.
In Python I can get the shape (dimensions) of a Numpy array/matrix using the .shape attribute, like so:
import numpy as np
m = np.array([ [ 1, 2, 3], [10, 20, 30] ])
print(m)
# [[ 1 2 3]
# [10 20 30]]
print(m.shape)
# (2, 3)
Now, when I use Eigen, there doesn't appear to be any attribute or method to retrieve the shape. What's the easiest way to do so?
#include <iostream>
#include "Eigen/Dense"
using std::cout;
using std::endl;
using std::string;
using Eigen::MatrixXd;
int main(int argc, char**argv)
{
MatrixXd m(2, 3);
m << 1, 2, 3, 10, 20, 30;
cout << m << endl;
// 1 2 3
// 10 20 30
cout << "shape: " << WHAT DO I PUT HERE? << endl;
return 0;
}