How I can use perms_reps(vec,reps) function with big vectors

11 views (last 30 days)
I used perms_reps(vec,reps) function (author:John D'Errico, the function :https://www.mathworks.com/matlabcentral/newsreader/view_thread/102182), it was very helpful, but the function crashed when I executed perms_reps([0 1],[40 5]) after around 24 hours of execution,due to the large number of permutations (1,221,759 permutations). I would like know if it's possible to use this function to found in each execution a part of permutation and in next execution the next part etc. Thank you for help.

Accepted Answer

Roger Stafford
Roger Stafford on 20 Dec 2016
For your particular problem, try this:
C = nchoosek(1:45,5);
n = size(C,1);
M = zeros(n,45);
% If you get this far without memory errors, you’re in business
for k = 1:n
M(k,C(k,:)) = 1;
end
If you have enough memory for C and M (M will be 1221759 by 45,) it might be faster than perms_reps since it avoids the overhead of recursive calls.
  1 Comment
slimani djamel
slimani djamel on 21 Dec 2016
Thank you so much Roger Stafford for this great answer, That's what I'm looking for.

Sign in to comment.

More Answers (1)

John D'Errico
John D'Errico on 20 Dec 2016
"YOUR" perms_reps function? Who are you talking to? This is not part of MATLAB, so must we guess? And then of course, we need to infer what the syntax is too? As a guess, is this referring to something I actually posted 11 years ago?
https://www.mathworks.com/matlabcentral/newsreader/view_thread/102182

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!