Contents:
GSL::Permutation.alloc(n)GSL::Permutation.calloc if you want to create a permutation
which is initialized to the identity. GSL::Permutation.calloc(n)GSL::Permutation#init()GSL::Permutation.memcpy(dest, src)GSL::Permutation#cloneGSL::Permutation#get(i)GSL::Permutation#swap(i, j)GSL::Permutation#sizeGSL::Permutation#validGSL::Permutation#valid?GSL::Permutation#reverseGSL::Permutation#inverseGSL::Permutation#nextGSL::SUCCESS. If no further permutations
are available it returns GSL::FAILURE and leaves self unmodified.
Starting with the identity permutation and repeatedly applying this function
will iterate through all possible permutations of a given order.GSL::Permutation#prevGSL_SUCCESS.
If no previous permutation is available it returns GSL_FAILURE
and leaves self unmodified.GSL::Permutation#fwrite(io)GSL::Permutation#fwrite(filename)GSL::Permutation#fread(io)GSL::Permutation#fread(filename)GSL::Permutation#fprintf(io, format = "%u\n")GSL::Permutation#fprintf(filename, format = "%u\n")GSL::Permutation#fscanf(io)GSL::Permutation#fscanf(filename)A permutation can be represented in both linear and cyclic notations. The functions described in this section convert between the two forms. The linear notation is an index mapping, and has already been described above. The cyclic notation expresses a permutation as a series of circular rearrangements of groups of elements, or cycles.
For example, under the cycle (1 2 3), 1 is replaced by 2, 2 is replaced by 3 and 3 is replaced by 1 in a circular fashion. Cycles of different sets of elements can be combined independently, for example (1 2 3) (4 5) combines the cycle (1 2 3) with the cycle (4 5), which is an exchange of elements 4 and 5. A cycle of length one represents an element which is unchanged by the permutation and is referred to as a singleton.
It can be shown that every permutation can be decomposed into combinations of cycles. The decomposition is not unique, but can always be rearranged into a standard canonical form by a reordering of elements. The library uses the canonical form defined in Knuth's Art of Computer Programming (Vol 1, 3rd Ed, 1997) Section 1.3.3, p.178.
The procedure for obtaining the canonical form given by Knuth is,
For example, the linear representation (2 4 3 0 1) is represented as (1 4) (0 2 3) in canonical form. The permutation corresponds to an exchange of elements 1 and 4, and rotation of elements 0, 2 and 3.
The important property of the canonical form is that it can be reconstructed from the contents of each cycle without the brackets. In addition, by removing the brackets it can be considered as a linear representation of a different permutation. In the example given above the permutation (2 4 3 0 1) would become (1 4 0 2 3). This mapping has many applications in the theory of permutations.
GSL::Permutation#linear_to_canonicalGSL::Permutation#to_canonicalGSL::Permutation.GSL::Permutation#canonical_to_linearGSL::Permutation#to_linearGSL::Permutation.GSL::Permutation#inversionsGSL::Permutation#linear_cyclesGSL::Permutation#canonical_cyclesGSL::Permutation::permute(v)GSL::Permutation::permute_inverse(v)GSL::Permutation.mul(pa, pb)