Boost logo

Ublas :

From: Gunter Winkler (guwi17_at_[hidden])
Date: 2007-06-08 17:34:54


Nico Galoppo wrote:
> Hi,
>
> I'm currently looking into writing a routine to convert a ublas type sparse
> matrix into a typical (row-oriented) compressed row storage (CRS) format, more
> specifically into a three arrays (values, columns & rowptr). Before I do so, I
> wanted to check with the list if this data is perhaps immediately available from
> the underlying storage in either compressed_matrix<> or coordinate_matrix<>?
> (their difference is unclear to me from the documentation).
>
You ask for compressed_matrix<double, row_major> and the 3 array are
index1_data() // aka row_ptr (pointer to the start of row k)
index2_data() // aka col_idx (column indices)
value_data() // values corresponding to col_idx

(I usually use: & index1_data()[0] to get the address of the first row_ptr)

BTW: compressed_matrix implements the standard (see netlib.org) CSR or
CSC storage schema,
coordinate_matrix implements the triplet storage (aka Harwell-Boeing stream)

mfg
Gunter

PS: look at ublas_csparse interface on
http://freenet-homepage.de/guwi17/ublas/