nthperm

버전 1.0.0.0 (4.21 KB) 작성자: Peter Li
Directly compute Nth lexicographic permutation
다운로드 수: 380
업데이트 날짜: 2013/12/31

라이선스 보기

Given a SORTED input vector V and positive integer n, rearranges V into its Nth lexicographic permutation. V must be SORTED or the behavior will not be correct. Sorted has flexible meaning however; see internal documentation.

Compare this with the output of my NEXTPERMS submission, which generates a series of sequential lexicographic pemutations in blocks. This instead generates the Nth permutation directly by a factorial radix rebasing; see http://en.wikipedia.org/wiki/Factorial_number_system for more information.

This will be much more efficient than running through the permutations sequentially if the desired permutation is deep in a large set.

Mex C++ and pure Matlab both provided; they should hopefully behave identically.

Basically the same idea as ONEPERM submission, but that submission generates the permutations in a recursive order, similar to the behavior of Matlab's PERMS. NTHPERM generates the permutation in lexicographic order to match NEXTPERMS, which is based on the C++ STL next_permutation function.

인용 양식

Peter Li (2024). nthperm (https://www.mathworks.com/matlabcentral/fileexchange/44887-nthperm), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2012a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 2-D and 3-D Plots에 대해 자세히 알아보기
도움

받음: ONEPERM

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0.0