tiswas
tiswas

Reputation: 2101

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!

Upvotes: 5

Views: 3777

Answers (2)

Svaberg
Svaberg

Reputation: 1681

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

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

Upvotes: 2

rerx
rerx

Reputation: 1183

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.

Upvotes: 0

Related Questions