Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to reduce the combinations' dimension--speed up my cross product
Date: Tue, 12 Jul 2011 07:29:09 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 24
Message-ID: <ivgt45$9jv$1@newscl01ah.mathworks.com>
References: <ivevlp$kdi$1@newscl01ah.mathworks.com> <ivf2lq$sq$1@newscl01ah.mathworks.com> <ivf45m$5qf$1@newscl01ah.mathworks.com> <ivfh09$gkk$1@newscl01ah.mathworks.com> <ivgrqs$6om$1@newscl01ah.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: www-03-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1310455749 9855 172.30.248.48 (12 Jul 2011 07:29:09 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 12 Jul 2011 07:29:09 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:735910

"Skirt Zhang" <silence_qunzi@hotmail.com> wrote in message <ivgrqs$6om$1@newscl01ah.mathworks.com>...
> Hi Roger,
> 
> Thanks a lot for your kind help.
> 
> So I will use this randperm to generate my index sequence and then according to this index I need to calculate the product of any three values. 
> 
> Is there a clever way to address this issue?
> BIG thanks

I strongly recommend to take a look a SHUFFLE by Jan Simon:
http://www.mathworks.com/matlabcentral/fileexchange/27076-shuffle

It's very efficient when the drawing population length (3) is much smaller than the total population (n):

b=rand(1,2000);
n = length(b);
m = 1000;
a = zeros(1,m);
for k=1:m
    a(k) = prod(b(Shuffle(n,'index',3)));
end

% Bruno