## C. y (Cycle-Direct)

1. Partitions the items of a given permutation y.

The result (a partition) is a list of boxed number lists, each part representing a cycle.

y can be

• a direct permutation on N points (which is a rearrangement of the list i.N)

• a partition as returned by C. when y is a direct permutation.

```   ] p=: 12?.12   NB. a sample "direct permutation"
6 11 1 7 10 3 8 9 0 2 4 5

C. p
+-----+----+--------------+
|8 0 6|10 4|11 5 3 7 9 2 1|
+-----+----+--------------+

C. C. p        NB. C. is self-inverse
6 11 1 7 10 3 8 9 0 2 4 5```

Meaning: the result of C. p

```+-----+----+--------------+
|8 0 6|10 4|11 5 3 7 9 2 1|
+-----+----+--------------+```

corresponds to an expression in conventional cycle notation like this:

`   p <--> (8 0 6)(10 4)(11 5 3 7 9 2 1)`

Since all rotations of a given cycle are equivalent, e.g.

```(8 0 6)
(6 8 0)
(0 6 8)```

a cycle representation has a canonical form showing the lowest number first, and omitting fixed points (e.g. (12)(13)(14)...)

• This is the reverse of what C. does.

`   p <--> (0 6 8)(4 10)(1 11 5 3 7 9 2)`

2. Calculates the parity of a given permutation p .

C.!.2 p returns one of 3 possible values:

•  1 Even parity _1 Odd parity 0 Not a permutation

Parity is an invariant property of a permutation. Even parity means that the permutation can be split into an even number of transpositions (2-cycles), not necessarily disjoint. There will be several distinct ways of doing this, but the number of transpositions will always be even.

```   z2=: <0 1          NB. a single transposition --> odd parity
z2 C. A            NB. -applied to 12 points
BACDEFGHIJKL
C. z2              NB. monadic C. returns a direct permutation, but the shortest possible.
1 0
C.!.2 (C. z2)      NB. Compute parity: _1 means Odd parity
_1```

```   z3=: (0 1);(2 3)   NB. two transpositions --> even parity
z3 C. A            NB. -applied to 12 points
C. z3              NB. monadic C. returns a direct permutation
1 0 3 2
C.!.2 (C. z3)      NB. Compute parity: 1 means Even parity
1```

### Common uses

Examine the cycle structure of a given permutation p (defined as above).

The cycle representation reveals many of the properties of p to a group theorist. Moreover the cycle representation is one of the most compact and convenient forms for handling permutations in books and hand-calculations.

## x C. y (Permute)

Permutes the items of any suitable list according to a given partition (as returned by monadic C. as above).

```   # A=: 'ABCDEFGHIJKL'  NB. a sample list of items ("points") to permute
12
] z=: C. p            NB. the cycle representation of p
+-----+----+--------------+
|8 0 6|10 4|11 5 3 7 9 2 1|
+-----+----+--------------+

p { A                 NB. use p to permute the list A
GLBHKDIJACEF
z C. A                NB. use z instead
GLBHKDIJACEF```

### Common uses

Return a permutation on more points than monadic C. will deliver.

• Such additional points will of course not be moved by the permutation.

```   z3=: (0 1);(2 3)
C. z3          NB. resulting permutation only defined on 4 points
1 0 3 2
z3 C. (i.12)   NB. define the permutation to be on 12 points
1 0 3 2 4 5 6 7 8 9 10 11```