Copyright | (C) Frank Staals |
---|---|

License | see the LICENSE file |

Maintainer | Frank Staals |

Safe Haskell | None |

Language | Haskell2010 |

Data type for representing a Permutation

## Synopsis

- type Orbit a = Vector a
- data Permutation a = Permutation {}
- orbits :: forall a a. Lens (Permutation a) (Permutation a) (Vector (Orbit a)) (Vector (Orbit a))
- indexes :: forall a. Lens' (Permutation a) (Vector (Int, Int))
- elems :: Permutation a -> Vector a
- size :: Permutation a -> Int
- cycleOf :: Enum a => Permutation a -> a -> Orbit a
- next :: Vector v a => v a -> Int -> a
- previous :: Vector v a => v a -> Int -> a
- lookupIdx :: Enum a => Permutation a -> a -> (Int, Int)
- apply :: Enum a => Permutation a -> a -> a
- orbitFrom :: Eq a => a -> (a -> a) -> [a]
- cycleRep :: (Vector v a, Enum a, Eq a) => v a -> (a -> a) -> Permutation a
- toCycleRep :: Enum a => Int -> [[a]] -> Permutation a
- genIndexes :: Enum a => Int -> [[a]] -> Vector (Int, Int)

# Documentation

data Permutation a Source #

Cyclic representation of a permutation.

## Instances

orbits :: forall a a. Lens (Permutation a) (Permutation a) (Vector (Orbit a)) (Vector (Orbit a)) Source #

elems :: Permutation a -> Vector a Source #

size :: Permutation a -> Int Source #

lookupIdx :: Enum a => Permutation a -> a -> (Int, Int) Source #

Lookup the indices of an element, i.e. in which orbit the item is, and the index within the orbit.

runnign time: \(O(1)\)

apply :: Enum a => Permutation a -> a -> a Source #

Apply the permutation, i.e. consider the permutation as a function.

orbitFrom :: Eq a => a -> (a -> a) -> [a] Source #

Find the cycle in the permutation starting at element s

cycleRep :: (Vector v a, Enum a, Eq a) => v a -> (a -> a) -> Permutation a Source #

Given a vector with items in the permutation, and a permutation (by its functional representation) construct the cyclic representation of the permutation.

toCycleRep :: Enum a => Int -> [[a]] -> Permutation a Source #

Given the size n, and a list of Cycles, turns the cycles into a cyclic representation of the Permutation.