perm.spad line 43 [edit on github]
Permutation(S) implements the group of all bijections on a set S, which move only a finite number of points. A permutation is considered as a map from S into S. In particular multiplication is defined as composition of maps: pi1 * pi2 = pi1 o pi2. The internal representation of permutations are two lists of equal length representing preimages and images.
coerce(ls) coerces a cycle ls, i.e. a list with not repetitions to a permutation, which maps ls.i to ls.i+1, indices modulo the length of the list. Error: if repetitions occur.
coerce(lls) coerces a list of cycles lls to a permutation, each cycle being a list with no repetitions, is coerced to the permutation, which maps ls.i to ls.i+1, indices modulo the length of the list, then these permutations are multiplied. Error: if repetitions occur in one cycle.
coerceImages(ls) coerces the list ls to a permutation whose image is given by ls and the preimage is fixed to be [1, ..., n]. Note: coerceImages(ls)=coercePreimagesImages([1, ..., n], ls). We assume that both preimage and image do not contain repetitions.
coerceListOfPairs(lls) coerces a list of pairs lls to a permutation. Error: if not consistent, i.e. the set of the first elements coincides with the set of second elements. coerce(p) generates output of the permutation p with domain OutputForm.
coercePreimagesImages(lls) coerces the representation lls of a permutation as a list of preimages and images to a permutation. We assume that both preimage and image do not contain repetitions.
cyclePartition(p) returns the cycle structure of a permutation p including cycles of length 1 only if S is finite.
degree(p) returns the number of points moved by the permutation p.
even?(p) returns true if and only if p is an even permutation, i.e. sign(p) is 1.
fixedPoints(p) returns the points fixed by the permutation p.
listRepresentation(p) produces a representation rep of the permutation p as a list of preimages and images, i.e p maps (rep.preimage).k to (rep.image).k for all indices k. Elements of S not in (rep.preimage).k are fixed points, and these are the only fixed points of the permutation.
movedPoints(p) returns the set of points moved by the permutation p.
numberOfCycles(p) returns the number of non-trivial cycles of the permutation p.
odd?(p) returns true if and only if p is an odd permutation i.e. sign(p) is -1.
order(p) returns the order of a permutation p as a group element.
sign(p) returns the signum of the permutation p, +1 or -1.
sort(lp) sorts a list of permutations lp according to cycle structure first according to length of cycles, second, if S has Finite or S has OrderedSet according to lexicographical order of entries in cycles of equal length.