hgeometry- Geometric Algorithms, Data structures, and Data types.

Safe HaskellNone





type Orbit a = Vector a Source

Orbits (Cycles) are represented by vectors

data Permutation a Source

Cyclic representation of a permutation.




_orbits :: Vector (Orbit a)
_indexes :: Vector (Int, Int)

idxes (fromEnum a) = (i,j) implies that a is the j^th item in the i^th orbit

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

indexes :: forall a. Lens' (Permutation a) (Vector (Int, Int)) Source

cycleOf :: Enum a => Permutation a -> a -> Orbit a Source

The cycle containing a given item

next :: Vector v a => v a -> Int -> a Source

Next item in a cyclic permutation

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.

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

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.

genIndexes :: Enum a => Int -> [[a]] -> Vector (Int, Int) Source

Helper stuff

ix' :: (Vector v a, Index (v a) ~ Int, IxValue (v a) ~ a, Ixed (v a)) => Int -> Lens' (v a) a Source

lens indexing into a vector