allperms | R Documentation |
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 all n!
permutations
of [n]
.
allcycn()
returns all (n-1)!
permutations of
[n]
comprising a single cycle of length n
.
allcyc(s)
returns all single-cycle permutations of set
s
. If s
has a repeated value, an opaque error
message is returned.
allpermslike(o)
takes a length-one vector o
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 partition
part
, as in a set of non-negative integers, and returns a
vector comprising every permutation of size sum(part)
with
shape part
that has its cycles in increasing order.
all_cyclic_shuffles(u)
takes a permutation u
and
returns a vector comprising of all permutations with the same shape
and cycle sets. It is vectorised so that argument u
may be a
vector of permutations.
all_perms_shape(p)
takes a permutation p
and
returns a vector of all permutations of size sum(p)
and shape
p
.
allperms(n)
allcycn(n)
allcyc(s)
allpermslike(o)
some_perms_shape(shape)
all_cyclic_shuffles(o)
all_perms_shape(shape)
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
|
Function allperms()
is very basic (the idiom is
word(t(partitions::perms(n)))
) but is here for completeness.
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.
Robin K. S. Hankin
M. C. Er 1989 “Efficient enumeration of cyclic permutations in situ”. International Journal of Computer Mathematics, volume 29:2-4, pp121-129.
allperms
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.