Path: news.mathworks.com!not-for-mail
From: "helper " <spamless@nospam.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Number of unique combinations from sets
Date: Wed, 7 May 2008 05:46:45 +0000 (UTC)
Organization: Timothy S. Farajian, Inc.
Lines: 45
Message-ID: <fvrfo5$l1l$1@fred.mathworks.com>
References: <fvr755$inh$1@fred.mathworks.com> <fvr8v7$h82$1@fred.mathworks.com> <fvrc2j$rtm$1@fred.mathworks.com>
Reply-To: "helper " <spamless@nospam.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1210139205 21557 172.30.248.38 (7 May 2008 05:46:45 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 7 May 2008 05:46:45 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1272923
Xref: news.mathworks.com comp.soft-sys.matlab:467089


"Daniel " <danielDOTrDOTlittle@gmail.com> wrote in message 
<fvrc2j$rtm$1@fred.mathworks.com>...

OK.  I guess you might want all combinations but where 
order is unimportant.  Playing with ALLCOMB, it is much 
better than COMBSREP.  Here is a quick adjustment you can 
make to the output of ALLCOMB to obtain what you are 
looking for:

tic
a = unique(sort(allcomb(1:900,1:900),2),'rows');
toc
Elapsed time is 0.927414 seconds.


In fact, the same author (Jos van der Geest) has a 
different function called COMBN which appears to be 
specific to drawing combinations from the same set (without 
replacement).  However, it is slowing than ALLCOMB when 
given the same set:

tic
a = allcomb(1:900,1:900);
toc
Elapsed time is 0.075114 seconds.

tic
b = combn(1:900,2);
toc
Elapsed time is 0.399549 seconds.

isequal(a,b)

ans =

     1

Jos should probably just call ALLCOMB from COMBN.  COMBN 
just allows you to use:

combn(1:20,4)

rather than having to use:

allcomb(1:20,1:20,1:20,1:20)