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.ndarray

    the permutation(s)

  • return_groups: bool

    return explicit cycle index lists rather than labels

  • :returns: np.ndarray | list

    per-position cycle labels, or the cycle groups


Feedback

Examples

Templates

Documentation