'How to get the number of rows and columns of an Eigen::MatrixXd?
I am trying to traverse Eigen::MatrixXd matrix
. However, there does not seem to be a function that returns the columns size nor the row size. Does anybody have an idea on how to do this?
Solution 1:[1]
This should work...
#include <Eigen/Dense>
int main()
{
Eigen::MatrixXd matrix(3, 4);
int r = matrix.rows();
int c = matrix.cols();
for (int i = 0; i < r; ++i)
{
for (int j = 0; j < c; ++j)
{
std::cout << matrix(i,j) << " ";
}
std::cout << std::endl;
}
return 0;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | keineahnung2345 |