Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!i6g2000yqj.googlegroups.com!not-for-mail
From: laxxy <laxyfoxx@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Vectorization
Date: Sun, 5 Jul 2009 04:47:11 -0700 (PDT)
Organization: http://groups.google.com
Lines: 18
Message-ID: <491153fb-0184-4438-997d-cacf25797dea@i6g2000yqj.googlegroups.com>
References: <8d98157c-ab47-40cb-8e4f-af119371a0db@h8g2000yqm.googlegroups.com> 
	<h2ohf4$ef0$1@fred.mathworks.com>
NNTP-Posting-Host: 165.124.165.249
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1246794431 31027 127.0.0.1 (5 Jul 2009 11:47:11 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sun, 5 Jul 2009 11:47:11 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: i6g2000yqj.googlegroups.com; posting-host=165.124.165.249; 
	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:552868


> > 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).
>
> W=Q*V(repmat((1:K)',1,N)+(P-1)*K);

Thanks!
But this is not quite the same though: in your solution each row of
the V(...) is permuted differently; but the i'th iteration of the loop
computes the same permutation on all rows of V which is specified
given by P(i,:)...