Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!h8g2000yqm.googlegroups.com!not-for-mail
From: laxxy <laxyfoxx@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Vectorization
Date: Sat, 4 Jul 2009 13:24:27 -0700 (PDT)
Organization: http://groups.google.com
Lines: 17
Message-ID: <8d98157c-ab47-40cb-8e4f-af119371a0db@h8g2000yqm.googlegroups.com>
NNTP-Posting-Host: 165.124.167.185
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Trace: posting.google.com 1246739067 16946 127.0.0.1 (4 Jul 2009 20:24:27 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sat, 4 Jul 2009 20:24:27 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: h8g2000yqm.googlegroups.com; posting-host=165.124.167.185; 
	posting-account=H75pegoAAAB4jLLQ9F_tD2S0MMEd66eY
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.11) 
	Gecko/2009060215 Firefox/3.0.11,gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:552810


Hi all --

I am wondering if it is possible to eliminate the loop in the
following piece of code:

for i=1:K
  W(i,:) = Q(i,:)*V(:,P(i,:));
end;

(that is: each row i of the result is computed by multiplying ith row
of matrix Q by a permutation of columns of V specified by the i'th row
of P).

Here Q is a KxK square matrix; and all other matrices are KxN. P is an
existing index matrix containing indices into columns of V.

I've tried a few things but so far have not had too much success... :(