COMBINATOR -combinations AND permutations

버전 1.3.0.0 (32.7 KB) 작성자: Matt Fig
Returns 1 of 4 different samplings on the set 1:N, taken K at a time.
다운로드 수: 11.3K
업데이트 날짜: 2010/9/9

라이선스 보기

COMBINATOR will return one of 4 different samplings on the set 1:N, taken K at a time. These samplings are given as follows:

PERMUTATIONS WITH REPETITION/REPLACEMENT
COMBINATOR(N,K,'p','r') -- N >= 1, K >= 0

PERMUTATIONS WITHOUT REPETITION/REPLACEMENT
COMBINATOR(N,K,'p') -- N >= 1, N >= K >= 0

COMBINATIONS WITH REPETITION/REPLACEMENT
COMBINATOR(N,K,'c','r') -- N >= 1, K >= 0

COMBINATIONS WITHOUT REPETITION/REPLACEMENT
COMBINATOR(N,K,'c') -- N >= 1, N >= K >= 0

Example:

combinator(4,2,'p','r') % Permutations with repetition
combinator(4,2,'p') % Permutations without repetition
combinator(4,2,'c','r') % Combinations with repetition
combinator(4,2,'c') % Combinations without repetition
ans =
1 1
1 2
1 3
1 4
2 1
2 2
2 3
2 4
3 1
3 2
3 3
3 4
4 1
4 2
4 3
4 4
ans =
1 2
1 3
1 4
2 1
2 3
2 4
3 1
3 2
3 4
4 1
4 2
4 3
ans =
1 1
1 2
1 3
1 4
2 2
2 3
2 4
3 3
3 4
4 4
ans =
1 2
1 3
1 4
2 3
2 4
3 4

The accompanying c++ file can be MEXed to provide the ability to specify N as an int8, int16, or int32. This saves memory and is faster. I have provided a MEX file that was created on Win XP with 2006a that may work. If not, the file will need to be MEXed on your machine.
Please READ the help before using.
I would very much appreciate bug reports sent through email, as well as suggestions for improvement. Thanks.

인용 양식

Matt Fig (2024). COMBINATOR -combinations AND permutations (https://www.mathworks.com/matlabcentral/fileexchange/24325-combinator-combinations-and-permutations), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2007a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Elementary Math에 대해 자세히 알아보기

Community Treasure Hunt

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

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

Previous update had left out the C++ source code.

1.2.0.0

Implemented changes suggested by Jan Simon.

1.1.0.0

Added ability to specify integer class for N. MEX-File.

1.0.0.0