Boost logo

Ublas :

Subject: Re: [ublas] Subrange or slice on sparse matrices
From: Gunter Winkler (guwi17_at_[hidden])
Date: 2008-11-30 08:17:38


Am Freitag, 28. November 2008 01:07 schrieb Umut Tabak:
> Dear all,
>
> While planning for some possible fe code generation, I tried to check
> the Ublas lib. I was wondering if subrange/slice capabilities also
> apply to sparse matrices? Or are there some tricks or workarounds to
> make this happen?

The range and slice operation work with all matrix types - including
sparse ones.

simply use project():

compressed_matrix<double> A(50000, 50000);
vector<double> x(5);
y = prod(project(A, range(0,50000), range(1000,1005)), x);

or

apxy_prod(project(A, range(0,50000), range(1000,1005)), x, y, false);
(which is more efficient ...)

mfg
Gunter

PS: However uBLAS default algorithms can still be beaten by handcoded,
optimized routines, see http://guwi17.de/ublas/matrix_sparse_usage.html

mfg
Gunter