views:

35

answers:

1

In boost::numeric::ublas, there are three sparse vector types.

I can see that the mapped_vector is essentially an stl::map from index to value, which considers all not-found values to be 0 (or whatever is the common value).

But the documentation is sparse (ha ha) on information about compressed_vector and coordinate_vector.

Is anyone able to clarify? I'm trying to figure out the algorithmic complexity of adding items to the various vectors, and also of dot products between two such vectors.

A very helpful answer offered that compressed_vector is very similar to compressed_matrix. But it seems that, for example, compressed row storage is only for storing matrices -- not just vectors.

I see that unbounded_array is the storage type, but I'm not quite sure what the specification is for that, either. If I create a compressed_vector with size 200,000,000, but with only 5 non-zero locations, is this less efficient in any way than creating a compressed_vector with size 10 and 5 non-zero locations?

Many thanks!

+1  A: 

replace matrix with vector and you have the answers

http://www.guwi17.de/ublas/matrix_sparse_usage.html

aaa
Many thanks! This is just what I needed.
mohawkjohn
@mohawkjohn for the product you probably want compressed_vector
aaa
Okay, so this doesn't completely answer my question after all. For example, the compressed_matrix is stored using compressed row storage. But the compressed_vector couldn't be stored that way, could it?
mohawkjohn
@mohawkjohn it certainly can, all it does is store contiguous blocks of nonzero elements.
aaa