Boost logo

Ublas :

From: Karl Meerbergen (Karl.Meerbergen_at_[hidden])
Date: 2007-09-04 03:44:42

Regis Behmo wrote:

>On 9/4/07, Karl Meerbergen <Karl.Meerbergen_at_[hidden]> wrote:
>>I am not familiar with a mapped_matrix, but for the coordinate_matrix
>>and compressed_matrix, it should be possible to implement a function to
>>remove a row or a column. I think you can easily do this yourself once
>>you are familiar with the format. Why do you use a mapped_matrix?
>Bonjour Karl,
>I am not familiar with many concepts that are used in the reference
>docs of ublas; therefore, the choice of the mapped_matrix structure is
>probably not entirely justified. I just want to use a sparse matrix
>and I don't know the difference between a mapped_matrix, a
>compressed_matrix and a coordinate_matrix.
>Right now, the only way I see to remove a line/column from a sparse
>matrix M (M being either compressed, mapped or coordinate) would be to
>make a copy of M and copy only the elements from the rows/columns
>outside the removed row/column.
>Do you see what I mean?
>Could you give me a clue as how to do it in a more time efficient way?
>ublas mailing list

Hi Regis,

The choice of sparse matrix depends on what you want to do with it.
For example, adding elements in any order is more efficient with
coordinate_matrix than with compressed_matrix.
A matrix times vector product is more efficient with the
compressed_matrix format.

Gunter has a webpage with timings on the choice of format in function of
the algorithm.

All is application dependent: in my finite element applications, I
usually first create the sparse matrix structure in coordinate format,
then create a compressed_matrix from that for use with a matrix vector
product and other algorithms.

The disadvantage of a mapped_matrix is that you are not going to be able
to create matrices of large dimension. I guess this is still the case?

To come to your question of removing a row/column from a sparse matrix:
I would do this by manipulating the index1_data(), index2_data(), and
value_data() of the matrix. But you need to be familiar with sparse
matrix formats to be able to do this swiftly. Unfortunately, I do not
have the time to write such routines for you.

It is rather technical: sparse matrices are more complex to manipulate
than dense ...

Nevertheless, I hope this is helpful.