
Ublas : 
From: Gunter Winkler (guwi17_at_[hidden])
Date: 20050204 14:21:56
Am Freitag, 4. Februar 2005 16:32 schrieben Sie:
> I do not understand this message. Does uBLAS use the same algorithm
> for multiplying matrices independent of if the storage is row major
> or column major ? This would be inefficient.
>
> On Fri, 4 Feb 2005, Gunter Winkler wrote:
> > But a large matrix vector multiplication using row major matrix is
> > always faster than using a column major matrix, because the latter
> > has a worse memory access pattern. (Except you call a specialized
> > dgemm() )
No. uBlas uses 2 different algorithms.
Let A be a nbyn matrix, x and y nvectors. We compute y = Ax.
case 1) row major storage
> use scalar products
for each row i do
y(i) = row(A, i) * x
each y(i) is updated exactly once.
case 2) column major storage
> add up scaled vectors
for each column j do
y = x(j) * column(A, j)
each y(i) is updated n times
Case 1 makes much better use of (read)pipelines and has less memory
writes than case 2. A much more comprehensive discussion can be found
in the ATLAS paper at
http://mathatlas.sourceforge.net/
If your are not convinced try yourself. My times are
size of matrix  5000x5000
R 0.31 C 2.21
mfg
Gunter