is there an alternative to nchoosek which is too slow?
7 views (last 30 days)
dpb on 29 Jul 2018
Edited: dpb on 29 Jul 2018
Well, you're asking for 40!/(10! 30!) elements -->
elements so it's not terribly surprising it might just take a while for the scribes to write 'em all down...
It boils down in the end to
function P = combs(v,m)
P = ;
if m < n && m > 1
for k = 1:n-m+1
Q = combs(v(k+1:n),m-1);
P = [P; [v(ones(size(Q,1),1),k) Q]]; %#ok
which has a big problem in time in that P isn't preallocated.
Unfortunately, combnk has the same flaw using almost identically the same code.
Whether somebody has supplied mex file or other solution on FEX I didn't research.