I need to store data in a 3D-like structure, however I've been relying on Eigen libraries to handle the matrix structures in my code, and Eigen doesn't supply 3D matrices. I've found two possible workarounds:
int x,y,z;
Eigen::Matrix<Eigen::Matrix<double,Dynamic,Dynamic>, Dynamic,1> M(z);
for (int i = 0; i < M.rows(); ++i) M(i)=MatrixXd::Zero(x,y);
// access coefficients with M(z)(x,y)
and
int x,y,z;
std::vector<Eigen::Matrix<double,Dynamic,Dynamic> > M(z);
for (int i = 0; i < M.rows(); ++i) M[i]=MatrixXd::Zero(x,y);
// access coefficients with M[z](x,y)
My question is: is there any speed/efficiency advantage in using either method, or are they equivalent?