sym-0.13.0: Permutations, patterns, and statistics

CopyrightAnders Claesson 2013-2016
MaintainerAnders Claesson <anders.claesson@gmail.com>
Safe HaskellNone
LanguageHaskell98

Sym.Perm

Description

Generating permutations: rank and unrank

Synopsis

Documentation

type Perm = CLongArray Source #

A permutation is just a CLongArray. By convention a permutation of size n is understood to be a permutation of [0..n-1].

emptyperm :: Perm Source #

The unique permutation length zero.

one :: Perm Source #

The unique permutation length one.

idperm :: Int -> Perm Source #

The identity permutation.

ebb :: Int -> Perm Source #

The reverse of the identity permutation.

mkPerm :: Ord a => [a] -> Perm Source #

Construct a permutation from a list of elements. As opposed to fromList this is a safe function in the sense that the output of mkPerm xs is guaranteed to be a permutation of [0..length xs-1]. E.g., mkPerm "baxa" == fromList [2,0,3,1].

rank :: Perm -> Integer Source #

The rank of the given permutation, where the rank is defined as in [W. Myrvold and F. Ruskey, Ranking and Unranking Permutations in Linear Time, Information Processing Letters, 79 (2001) 281-284].

unrank :: Int -> Integer -> Perm Source #

The permutation of size n whose rank is r, where the rank is defined as in [W. Myrvold and F. Ruskey, Ranking and Unranking Permutations in Linear Time, Information Processing Letters, 79 (2001) 281-284].

perms :: Int -> [Perm] Source #

All permutations of a given size.