Boost logo

Ublas :

Subject: Re: [ublas] CSR MATRIX creation from 3 arrays
From: Gunter Winkler (guwi17_at_[hidden])
Date: 2009-07-23 16:24:20

Riccardo Rossi schrieb:
> Hi everyone.
> I would like a hint on the creation of a compressed_matrix in
> ublas:
> i have currently three vectors of the type (Say)
> double* values
> int* column_indices
> int* row_indices
> exactly the same as the internals that are needed inside the ublas
> compressed matrix. I also know all of the data i may wish to have on my
> matrix.
> How can i use this data to construct a ublas matrix ... without doing a
> copy? (a bit in the spirit of the carray stuff ...)
I think this is currently not supported at all. The problem is, that you
essentially need a read only CSR adaptor. However there is currently no
"read only" concept. There are some possible solutions:

1) copy the data using push_back(i,j,t) - it already works, but it is
the worst solution
2) improve the compessed_matrix class to be able to handle external
storage (maybe with "copy on write", or "copy on structure change"
policy) - this is the most elegant solution, but requires some work.
3) write a CSR adaptor that provides a read only view of a CSR matrix -
this should come together with a read only matrix concept.
> The issue i describe is very frequently encountered in many different
> contexts. For example i may wish to allocate myself the values and
> column_indices vectors so to have control on the data locality in
> openmp
> any suggestion on this would be very welcome
> thank you for the attention
> Riccardo