
Ublas : 
From: Nico Galoppo (nico_at_[hidden])
Date: 20060705 07:35:13
Gunter Winkler wrote:
> On Wednesday 05 July 2006 11:08, Nico Galoppo wrote:
>> Therefore, I changed my code to fill a temporary
>> ublas::generalized_vector_of_vector< real_type, row_major,
>> ublas::vector<compressed_vector<real_type> > > first, then assigning to the
>> compressed_matrix as such: C.assign(tmp);
>>
>> The fill time has improved from 150s (compressed_matrix) to 0.9 s (fill of
>> vector_of_vector) + 29 s (assignment).
>>
>> I was wondering if there may be an even faster way.
>
> The fastest way is to precompute the sparsity pattern and prepare a compressed
> matrix with it. In my programs I now use a coordinate matrix which is a good
> compromise between speed of insertion (using +=), storage requirement and
> multiplication speed. Maybe you can speed up the insertion a little if you
> modify the constructor of gvov to pass the number of non_zeroes to the
> constructor of vector_data_value_type (=compressed vector). Unfortunately,
> this cannot be done in general because non_zeroes is not part of the general
> vector concept.
Actually, I'm quite happy with the gvov random fill efficiency (0.09 s actually,
0.9 was a typo). :)
But anyway, for assignment, I first resize the compressed_matrix and then use
assign:
tmp.resize(n,n);
// do random inserts in tmp
C.resize(n,n);
C.assign(tmp);
This last call takes about 29s. I am not very familiar with ublas internals, so
I'm not sure how hard it would be for me to change the constructor of
vector_data_value_type.
On a side note, are you saying that I should consider using coordinate_matrix
instead of the above approach, because the performance of my algorithms will
hardly change? Basically, all I'm using the sparse matrix for, is a
(nonpreconditioned) linear CG. The CG algorithm was coded by me, using atlas
bindings. I'm considering switching to lapack bindings + GOTO blas linking.
nico
 Nico Galoppo UNCCH :: ETHZ http://www.ngaloppo.org +41774319939