Author(s): F. Beck, T. Lindelöf | Library: MATHLIB |
Submitter: K.S. Kölbig | Submitted: 15.09.1978 |
Language: Fortran | Revised: 07.06.1992 |
Successive calls to
subroutine subprogram PERMU will generate all permutations of a
set of integers of total length N consisting of repetitions of
the integer 1, followed by
repetitions of the integer
etc, concluding with
repetitions of the integer m, where
.
Subroutine subprogram PERMUT generates directly a single
member of the set of all lexicographically ordered permutations of the
first integers , as specified by its
lexicographical ordinal.
Successive calls to subroutine subprogram COMBI will generate all
the possible combinations without repetition of
integers from the set
.
Structure:
SUBROUTINE subprogram
User Entry Names: PERMU, PERMUT, COMBI
Files Referenced: Unit 6
Usage:
Subroutine PERMU:
CALL PERMU(IA,N)
CALL PERMUT(NLX,N,IP)
CALL COMBI(IC,N,J)
Examples:
This set consists of m=8 sequences of length ,
,
. Thus, in order to get the possible
permutations, set
before calling PERMU(IA,12) the first time.
CALL PERMUT( 2,4,IP) | sets | ![]() | |
CALL PERMUT( 3,4,IP) | sets | ![]() | |
CALL PERMUT(24,4,IP) | sets | ![]() |
... IA(1)=0 1 CALL COMBI(IC,6,3) IF(IC(1) .NE. 0) THEN PRINT *, IC(1),IC(2),IC(3) GO TO 1 ENDIF ...
Restrictions:
PERMUT: .
COMBI: .
Error handling:
If any of the above conditions is not satisfied, a message is written on Unit 6.
Notes:
where . This number can become large even
for seemingly simple cases, e.g. in Example 1 above,