permutation_cycles
permutation_cycles(perms, return_groups=False):
LLM Docstring
Decompose permutations into their disjoint cycles.
Assigns each position a cycle label (an integer group id); with
return_groups set, the actual cycle index lists are returned instead. Cannot
be vectorized past 2D, so batched inputs beyond a single stack are rejected when
groups are requested.
perms:np.ndarraythe permutation(s)
return_groups:boolreturn explicit cycle index lists rather than labels
:returns:np.ndarray | listper-position cycle labels, or the cycle groups