tags:

views:

85

answers:

2

I want a matrix container class that has similar functionality to vector<vector<type>>, but stores elements in contiguous memory. I bet there is none in the standard library (including C++0x); does Boost provide one?

+3  A: 

It looks like you want the misleadingly-named Boost Matrix.

The templated class matrix is the base container adaptor for dense matrices. For a (m x n)-dimensional matrix and 0 <= i < m, 0 <= j < n every element mi, j is mapped to the (i x n + j)-th element of the container for row major orientation or the (i + j x m)-th element of the container for column major orientation.

T.E.D.
erjot
@erjot - Interesting. That more or less directly contradicts the quoted section above. To be honest, I figured it was going to be the "dynamic" part that would cause you grief, not the "contiguous".
T.E.D.
@T.E.D., Boost.Matrix is being created in row-major order by default and I needed column-major order, that's why it wasn't working - hint found on other SO topic.
erjot
A: 

I think Boost.MultiArray does what you want.

Rhys Ulerich