For a robotics project I need a 3D matrix of a pre-defined size. Using the Eigen library, I don't see how:
1.) to create a large pre-defined matrix, seems like I have to use matrixXd but that's for a dynamic matrix.
2.) create a 3D matrix, i. e. size = (int from 200 to 1000) and matrix (size, size, size)
1
votes
2 Answers
1
votes
0
votes
Well, I find a way to build a 3d matrix in my project. Use the vector:
typedef vector<Matrix<double, Dynamic, Dynamic>> M3;
If you want to initialize a pre-defined matrix with dimension (k,m,n), just use:
M3 W(k, M2(m, n));
This way is easy to store Eigen Matrix. But if you want to calculate 3d matrix, you should slice it to many 2d Matrix and use a loop to get the 3d result.
Matrix
is allocated on the stack, whereas the dynamicMatrixXd
is allocated on the heap. – Avi Ginsburg