Flint2-0.1.0.5: Haskell bindings for the flint library for number theory
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Number.Flint.Groups.Perm

Description

 
Synopsis

Permutations

_perm_init :: CLong -> IO (Ptr CLong) Source #

_perm_init n

Initialises the permutation for use.

_perm_clear :: Ptr CLong -> IO () Source #

_perm_clear vec

Clears the permutation.

Assignment

_perm_set :: Ptr CLong -> Ptr CLong -> CLong -> IO () Source #

_perm_set res vec n

Sets the permutation res to the same as the permutation vec.

_perm_set_one :: Ptr CLong -> CLong -> IO () Source #

_perm_set_one vec n

Sets the permutation to the identity permutation.

_perm_inv :: Ptr CLong -> Ptr CLong -> CLong -> IO () Source #

_perm_inv res vec n

Sets res to the inverse permutation of vec. Allows aliasing of res and vec.

Composition

_perm_compose :: Ptr CLong -> Ptr CLong -> Ptr CLong -> CLong -> IO () Source #

_perm_compose res vec1 vec2 n

Forms the composition \(\pi_1 \circ \pi_2\) of two permutations \(\pi_1\) and \(\pi_2\). Here, \(\pi_2\) is applied first, that is, \((\pi_1 \circ \pi_2)(i) = \pi_1(\pi_2(i))\).

Allows aliasing of res, vec1 and vec2.

Randomisation

_perm_randtest :: Ptr CLong -> CLong -> Ptr CFRandState -> IO CInt Source #

_perm_randtest vec n state

Generates a random permutation vector of length \(n\) and returns its parity, 0 or 1.

This function uses the Knuth shuffle algorithm to generate a uniformly random permutation without retries.

Input and output

_perm_print :: Ptr CLong -> CLong -> IO CInt Source #

_perm_print vec n

Prints the permutation vector of length \(n\) to stdout.

_perm_print_pretty :: Ptr CLong -> CLong -> IO CInt Source #

_perm_print_pretty vec n

Prints permutation vector of length \(n\) in cycle representation to stdout.

_perm_fprint_pretty :: Ptr CFile -> Ptr CLong -> CLong -> IO () Source #

_perm_fprint_pretty vec n

Prints permutation vector of length \(n\) in cycle representation to file.

_perm_get_str_pretty :: Ptr CLong -> CLong -> IO CString Source #

_perm_get_str_pretty vec n

Return a string representation of permutation vector of length \(n\) in cycle representation.

Properties

_perm_parity :: Ptr CLong -> CLong -> IO CInt Source #

_perm_parity vec n

Returns the parity of vec, 0 if the permutation is even and 1 if the permutation is odd.