Finding unique permutations efficiently

后端 未结 1 932
说谎
说谎 2021-01-04 18:59

I have the following problem. I need to compute the permutations of a set; however, the set may contain two elements which are the same and therefore cause repeated permuta

相关标签:
1条回答
  • 2021-01-04 19:56

    It would appear this is a regularly occurring problem. Here is a file by John d'Errico (uniqueperms) that seems to tackle it pretty effectively. As an alternative, there is another FEX submission here by Ged Ridgway; you'll have to profile a bit to see which one is faster.

    Note that due to the limitations of Matlab's JIT, loops are not accelerated if they call non-builtin functions, so it might be beneficial to copy-paste the contents of these functions (and/or specialize them a bit) inside your loop(s).

    0 讨论(0)
提交回复
热议问题