Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the differences between the various boost ublas sparse vectors?

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!

like image 285
Translunar Avatar asked Aug 03 '10 18:08

Translunar


People also ask

Why do we need sparse vector?

A sparse vector is used for storing non-zero entries for saving space. It has two parallel arrays: One for indices. The other for values.

What is meant by sparse vector?

A sparse vector is a vector having a relatively small number of nonzero elements. Consider the following as an example of a sparse vector x with n elements, where n is 11, and vector x is: (0.0, 0.0, 1.0, 0.0, 2.0, 3.0, 0.0, 4.0, 0.0, 5.0, 0.0) In Storage.


1 Answers

replace matrix with vector and you have the answers

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

like image 120
Anycorn Avatar answered Oct 06 '22 01:10

Anycorn