Copyright | (c) A. V. H. McPhail 2010 |
---|---|
License | BSD3 |
Maintainer | haskell.vivian.mcphail <at> gmail <dot> com |
Stability | provisional |
Portability | uses ffi |
Safe Haskell | None |
Language | Haskell2010 |
GSL permutation functions
- data Permutation
- data CanPerm
- random_permute :: Int -> Int -> Permutation
- get :: Permutation -> Int -> Int
- swap :: Permutation -> Int -> Int -> Permutation
- swapList :: Permutation -> [(Int, Int)] -> Permutation
- size :: Permutation -> Int
- valid :: Permutation -> Bool
- reverse :: Permutation -> Permutation
- inverse :: Permutation -> Permutation
- next :: Permutation -> IO Bool
- prev :: Permutation -> IO Bool
- permute :: Permutation -> Vector Double -> Vector Double
- inverse_permute :: Permutation -> Vector Double -> Vector Double
- mul :: Permutation -> Permutation -> Permutation
- fwritePermutation :: FilePath -> Permutation -> IO ()
- freadPermutation :: FilePath -> Int -> IO Permutation
- fprintfPermutation :: FilePath -> String -> Permutation -> IO ()
- fscanfPermutation :: FilePath -> Int -> IO Permutation
- canonical :: Permutation -> CanPerm
- linear :: CanPerm -> Permutation
- inversions :: Permutation -> Int
- cyclesLinear :: Permutation -> Int
- cyclesCanonical :: CanPerm -> Int
Documentation
data Permutation Source
A permutation structure
get :: Permutation -> Int -> Int Source
returns the value of the i-th element of the permutation
swap :: Permutation -> Int -> Int -> Permutation Source
swaps the i-th and j-th elements
swapList :: Permutation -> [(Int, Int)] -> Permutation Source
swaps pairs of elements
size :: Permutation -> Int Source
get the length of the permutation
valid :: Permutation -> Bool Source
checks that the permutation is valid
reverse :: Permutation -> Permutation Source
reverse the elements of the permutation
inverse :: Permutation -> Permutation Source
computes the inverse of the permutation
next :: Permutation -> IO Bool Source
advances the permutation to the next in lexicographic order, if there is one
prev :: Permutation -> IO Bool Source
steps the permutation back to the previous in lexicographic order, if there is one
inverse_permute :: Permutation -> Vector Double -> Vector Double Source
apply the inverse permutation to a vector
mul :: Permutation -> Permutation -> Permutation Source
multiply two permutations, P = PA * PB
fwritePermutation :: FilePath -> Permutation -> IO () Source
write a permutation in the native binary format (may not be portable)
freadPermutation :: FilePath -> Int -> IO Permutation Source
read a permutation in the native binary format, length must be known
fprintfPermutation :: FilePath -> String -> Permutation -> IO () Source
saves the permutation with the given format
fscanfPermutation :: FilePath -> Int -> IO Permutation Source
reads formatted data as written by fprintf, the number of bins must be known in advance
canonical :: Permutation -> CanPerm Source
compute the canonical form
linear :: CanPerm -> Permutation Source
convert from canonical to linear
inversions :: Permutation -> Int Source
a count of the inversions
cyclesLinear :: Permutation -> Int Source
a count of the cycles of a permutation in linear form
cyclesCanonical :: CanPerm -> Int Source
a count of the cycles of a permutation in canonical form