Boost logo

Boost Users :

Subject: [Boost-users] [ublas] bounded_vector redundant storage of size. (is this a bug?)
From: johanngoetz (jgoetz_at_[hidden])
Date: 2008-10-24 11:23:41

for small vectors (geometry vectors is what I have in mind) the
bounded_vector and bounded_matrix look promising. Indeed, if I was only
dealing with a handful of vectors at a time, this would be ideal. However, I
am creating a fieldmap (of a magnetic field, say) which maps 3D vectors
(position) to 3D vectors (the field). The likely size of this map is around
a million points. This should correspond to 6 million numbers stored.
However, if I have something like:

    ublas::bounded_vector<int, 3>,
    ublas::bounded_vector<float, 3> >

Then the size is actually 8 million numbers stored since I am storing the
size of each of the bounded_vectors. While access time to the map is still
very fast, I find that reading in or creating such maps takes much more time
than should be required.

It seems to me that the advantage of having the size as a template parameter
is: not needing to store it as a member variable. Therefore I would like to
say this is a bug (do I have agreement?). Unfortunately, the only solution
for ublas::bounded_vector I can think of would be a complete
reimplementation of ublas::vector just with the size as a template parameter
instead of a member variable. but maybe I don't know enough to suggest the
proper way to handle such situations.
Of course the same applies to ublas::bounded_matrix but the effect there is
not as big and it is hard to imagine off-hand a huge array of matrices.
--- Johann

View this message in context:
Sent from the Boost - Users mailing list archive at

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at