|
Ublas : |
Subject: Re: [ublas] Fast compressed_matrix from CSR/CSC triplets
From: Ungermann, Jörn (j.ungermann_at_[hidden])
Date: 2012-06-11 17:17:14
Hi,
in case memory is not such an issue, the fastest way would be in my
experience to first fill a coordinate_matrix of the correct majority and
then construct a compressed_matrix from the coordinate_matrix. Just use
append_element for the insertion into the coordinate_matrix, else the
constant sorting will kill the performance.
If memory is an issue, you need to sort your triplets first in an efficient
way. Using the coordinate_matrix does basically the sorting for you (it will
be sorted automatically once using std algorithms upon construct the
compressed_matrix).
Cheers,
Jörn
> -----Original Message-----
> From: ublas-bounces_at_[hidden] [mailto:ublas-
> bounces_at_[hidden]] On Behalf Of Rishi Amrit
> Sent: Donnerstag, 31. Mai 2012 15:12
> To: ublas_at_[hidden]
> Subject: Re: [ublas] Fast compressed_matrix from CSR/CSC triplets
>
> Just to add to the woes, I may have the row/column indices vector (i.e.
> the one that corresponds to index2_data()) as unsorted.
>
> On Thu, May 31, 2012 at 2:24 PM, Rishi Amrit <rishiamrit_at_[hidden]>
> wrote:
> > Hi,
> >
> > This might be trivial question, but I need to construct a
> > compressed_matrix from CSR / CSC triplets.
> > At the moment I'm using a nested for loop and using push_back, but
> > this is very slow. There has to be a faster way of constructing the
> > sparse matrix object from the CSR triplets. Any ideas ?
> >
> > R