0

I have a 3D C++ vector of vectors defined as follows.

vector<vector<vector<float>>> vec3DCpp;

vec3DCpp has a variable size in each of its dimension. I am trying to find a data type in Eigen similar to vectors of vectors in C++. Does Eigen have anything similar to this? If it does, how would mapping vec3DCpp to vec3DEigen look like?

If this is not possible, is there anyway to convert/map vec3DCpp to an Eigen variable?

I would appreciate any help.

afp_2008
  • 1,940
  • 1
  • 19
  • 46
  • 4
    Note that vector of vector of vector is not the same thing as a 3D array. For one thing, a vector of 1000 vectors of 1000 vectors of 1000 floats will perform 1001001 allocations (and spread the data in that much different memory chunks), while an actual 3D array would perform just one. – spectras Jan 23 '20 at 00:01
  • 2
    maybe even more allocations than that, if they are not pre-allocated. – Not a real meerkat Jan 23 '20 at 00:06
  • What if we already have `vec3DCpp` and we want to map it to some types in Eigen? Is this possible? – afp_2008 Jan 23 '20 at 00:07
  • 1
    @AFP You are looking for the `Map` type https://eigen.tuxfamily.org/dox/group__TutorialMapClass.html – serkan.tuerker Jan 23 '20 at 00:28
  • 1
    Does this answer your question? [Eigen and std::vector](https://stackoverflow.com/questions/33668485/eigen-and-stdvector) – Avi Ginsburg Jan 23 '20 at 09:44
  • 1
    Are you sure you need such a type? Maybe a std::vector would be sufficient? – mfnx Jan 23 '20 at 10:00
  • 1
    Have you considered using [the Tensor module](http://eigen.tuxfamily.org/dox-devel/unsupported/group__CXX11__Tensor__Module.html)? – chtz Jan 23 '20 at 15:11

0 Answers0