/******************************************************************************

    Copyright (C) 2011 Sebastian Pancratz

******************************************************************************/

*******************************************************************************

    Memory management

*******************************************************************************

long * _perm_init(long n)

    Initialises the permutation for use.

void _perm_clear(long *vec)

    Clears the permutation.

*******************************************************************************

    Assignment

*******************************************************************************

void _perm_set(long *res, const long *vec, long n)

    Sets the permutation \code{res} to the same as the permutation \code{vec}.

void _perm_set_one(long *vec, long n)

    Sets the permutation to the identity permutation.

void _perm_inv(long *res, const long *vec, long n)

    Sets \code{res} to the inverse permutation of \code{vec}.

*******************************************************************************

    Composition

*******************************************************************************

void _perm_compose(long *res, const long *vec1, const long *vec2, long 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 \code{res} and \code{vec2}, but not of \code{res} 
    and \code{vec1}.

*******************************************************************************

    Randomisation

*******************************************************************************

void _perm_randtest(long *vec, long n, flint_rand_t state)

    Generates a random permutation vector of length $n$.

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

*******************************************************************************

    Input and output

*******************************************************************************

int _perm_print(const long * vec, long n)

    Prints the permutation vector of length $n$ to \code{stdout}.

