allperms {permutations} | R Documentation |
All permutations with given characteristics
Description
Functionality to enumerate permutations given different
characteristics. In the following, n
is assumed to be a
non-negative integer. Permutations, in general, are coerced to cycle
form.
allperms(n)
returns alln!
permutations of[n]
.allcycn()
returns all(n-1)!
permutations of[n]
comprising a single cycle of lengthn
.allcyc(s)
returns all single-cycle permutations of sets
. Ifs
has a repeated value, an opaque error message is returned.allpermslike(o)
takes a length-one vectoro
of permutations and returns a vector comprising permutations with the same shape and cycle sets as it argument.some_perms_shape(part)
takes an integer partitionpart
, as in a set of non-negative integers, and returns a vector comprising every permutation of sizesum(part)
with shapepart
that has its cycles in increasing order.all_cyclic_shuffles(u)
takes a permutationu
and returns a vector comprising of all permutations with the same shape and cycle sets. It is vectorised so that argumentu
may be a vector of permutations.all_perms_shape(p)
takes a permutationp
and returns a vector of all permutations of sizesum(p)
and shapep
.
Usage
allperms(n)
allcycn(n)
allcyc(s)
allpermslike(o)
some_perms_shape(shape)
all_cyclic_shuffles(o)
all_perms_shape(shape)
Arguments
shape |
A set of strictly positive integers, interpreted as the shape of a partition |
s |
A set of strictly positive integers, interpreted as a set on which permutations are defined |
n |
The size of the permutation |
o |
A vector of permutations, coerced to cycle form. Function
|
Details
Function allperms()
is very basic (the idiom is
word(t(partitions::perms(n)))
) but is here for completeness.
Note
Function allcyc()
is taken directly from Er's
“fine-tuned” algorithm. It should really be implemented in
C as part of the partitions package but I have not
yet got round to this.
Author(s)
Robin K. S. Hankin
References
M. C. Er 1989 “Efficient enumeration of cyclic permutations in situ”. International Journal of Computer Mathematics, volume 29:2-4, pp121-129.
See Also
Examples
allperms(5)
allcycn(5)
allcyc(c(5,6,8,3))
allpermslike(as.cycle("(12)(34)(5678)"))
allpermslike(rgivenshape(c(1,1,3,4)))
some_perms_shape(c(2,2,4))
all_cyclic_shuffles(cyc_len(3:5))
all_perms_shape(c(2,2,3))