Choose function too slow
Show older comments
Dear All,
i try to run
index=nchoosek(1:200, 10);
it talks a lot of time
is there exist any code that can be more faster.
Thanks in Advance.
Answers (4)
Image Analyst
on 3 Sep 2012
Look at the number of rows it would return:
>> factorial(200)./(factorial(200-10)* factorial(10))
ans =
NaN
>> factorial(200)
ans =
Inf
What do you really want to do. I doubt you need to do it this way. Perhaps rand or randperm might work for you.
1 Comment
Walter Roberson
on 3 Sep 2012
The number of possibilities is about 2.2E+16
Walter Roberson
on 3 Sep 2012
1 vote
An array that large cannot be done on any platform supported by MATLAB. It is 22451004309013280 outputs, each 10 entries long. Now, 200 is a number that fits within 8 bits so in theory the individual entries could be a single uint8 (a byte each); that still requires 2^(57.64) bytes of memory. No released x86 CPU has been designed that uses more than 48 bits of memory addressing, so your problem is 2^(ceil(57.64)-48) = 1024 times larger than is possible on any supported platform at this time.
Jan
on 3 Sep 2012
0 votes
FEX: VChooseK is much faster than Matlab's nchoosek. But for your job a really large memory is required. So think twice if you really need such a giantic array.
Hassan
on 3 Sep 2012
0 votes
2 Comments
Walter Roberson
on 3 Sep 2012
So see that URL and load in a compiler and SDK.
Jan
on 4 Sep 2012
You find several threads about installing a compiler in this forum.
Did you follow my advice to think twice?
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!