简体   繁体   中英

4 dimensional matrix in Armadillo

I started using Armadillo relatively recently, and although I like it a lot, it would be useful if it had ways of storing 4D matrices. Is there something I'm missing, or a workaround for this?

The last dimension would just have a size of three, so in theory I could have something like:

std::vector<arma::cube> 4Dmatrix(3);
for (int index=0; index<3; index++)
  4Dmatrix[index] = cube(size1, size2, size3);

However, it feels like there must be a better way.

Thanks in advance!

You could potentially use the field class which stores arbitrary objects as elements in a vector, matrix or cube structure. Eg (from the documentation) to create a field containing vec vectors:

// create a field containing vectors
field<vec> F(3,2);

No, there is no built-in way. If you look at the source, you will see that there are individual implementations for vectors, matrices and cubes.

Maybe a Boost multi array could be of use to you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM