Hi Pierre,

I appreciate your categorical answer, you saved me a lot of time. :-) Actually, i'm using std::vector< std::vector<> >, but things will explode when working with a real case. Sadly my matrices hasn't a defined structure, i'll try to redesign the algorithm to avoid this memory consumption.

Best regards,
Júlio.

2011/9/7 Pierre-Andre Noel <noel.pierre.andre@gmail.com>
No, Boost.MultiArray is not what you are looking for.

Boost.MultiArray is for data organized as a multi-dimensional "box": each of its dimension has a specified size. In 3D, these can be understood as height, width and length. Memory is allocated for every possible elements within this box, no exception.


> a00 a01 a02 a03 a04 a05 a06 a07 a08
> a10 a11 a12 a13 a14
> a20 a21 a22
> a30 a31
> a40

For your 2D example, you could use a vector of vector.

std::vector< std::vector< my_type > > storage(5); // Your example has 5 lines.
storage[0].resize(9); // The first line of your example has 9 elements.
storage[1].resize(5); // The second line of your example has 5 elements.
storage[2].resize(3); // ...
storage[3].resize(2);
storage[4].resize(1);

If your data is organized according to a "simplex" topology (the multi-dimensional extension of a triangular matrix, see http://en.wikipedia.org/wiki/Simplex ), then I may have something for you. Contact me again and I will give you further information. However, from your example, I guess that this is not the case.

Pierre-André Noël

2011/9/7 Júlio Hoffimann <julio.hoffimann@gmail.com>
Dear all,

By reading Boost.MultiArray docs, i haven't figured out any possible way to deal with unbalanced matrices. The following picture explains what i mean by unbalanced:

// two dimensional unbalanced matrix:

a00 a01 a02 a03 a04 a05 a06 a07 a08
a10 a11 a12 a13 a14
a20 a21 a22
a30 a31
a40

Each row has it's own extent (defined at runtime). Seems multi_array<> classes are not designed to increase it's subcontainers decoupled, and at a given depth, they always share the same extent? Could you confirm or guide me in how to achieve this behavior? I really need to save memory due to large 3D matrices.

Regards,
Júlio.

_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users


_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users