[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: fastest way to element-by-element multiply matix by vector?
From: |
Benjamin Lindner |
Subject: |
Re: fastest way to element-by-element multiply matix by vector? |
Date: |
Wed, 20 Jun 2007 06:59:48 +0200 |
> Hello all,
> I need to element-by-element multiply an nXk matrix A by an nX1 vector b,
> so
> that the result is that each row of A is multiplied by the corresponding
> row of
> b. This is on the inside loop of some intense calculations, so I'd like
> the best
> performance. Is C = A .* repmat(b,1,k) the best way to do this?
> Thanks, Michael
given that size(A)==[n,k] and size(b)==[n,1] I would have done it simply as
C = b*A
which also works if you do not have sparse matrix support.
I have no comparison in speed to the sparse diagonal veriant, but if
you have optimized blas/lapack this should be fastest and consume least
memory.
benjamin
--
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
Browser-Versionen downloaden: http://www.gmx.net/de/go/browser
Re: fastest way to element-by-element multiply matix by vector?,
Benjamin Lindner <=