 NAME
 VERSION
 SYNOPSIS
 METHODS
 METHODS TO BE INPLEMENTED
 AUTHOR
 BUGS
 SUPPORT
 REFERENCES
 LICENSE AND COPYRIGHT
NAME
Math::Permutation  pure Perl implementation of functions related to the permutations
VERSION
Version 0.01
SYNOPSIS
use Math::Permutation;
my $foo = Math::Permutation>cycles([[1,2,6,7], [3,4,5]]);
say $foo>sprint_wrepr;
# "2,6,4,5,3,7,1"
my $bar = Math::Permutation>unrank(5, 19);
$bar>comp($foo);
say $bar>sprint_cycles;
# (2 5 4 3)
# Note that there is no canonical cycle representation in this module,
# so each time the output may be slightly different.
my $goo = Math::Permutation>clone($foo);
say $goo>sprint_cycles;
# (1 2 6 7) (4 5 3)
$foo>inverse;
say $foo>sprint_cycles;
# (4 3 5) (1 7 6 2)
$foo>comp($goo);
say $foo>sprint_cycles;
# ()
say $bar>rank; # 19
$bar>prev;
say $bar>rank; # 18
say $goo>rank; # 1264
$goo>nxt;
say $goo>rank; # 1265
say $goo>is_even; # 0
say $goo>sgn; # 1
use Data::Dump qw/dump/;
say $bar>sprint_wrepr;
dump $bar>matrix;
# "1,4,5,3,2"
# [
# [1, 0, 0, 0, 0],
# [0, 0, 0, 0, 1],
# [0, 0, 0, 1, 0],
# [0, 1, 0, 0, 0],
# [0, 0, 1, 0, 0],
# ]
METHODS
INITALIZE/GENERATE NEW PERMUTATION
 $p>init($n)

Initialize $p with the identity permutation of $n elements.
 $p>wrepr([$a, $b, $c, ..., $m])

Initialize $p with word representation of a permutation, a.k.a. oneline form.
 $p>tabular([$a, $b, ... , $m], [$pa, $pb, $pc, ..., $pm])

Initialize $p with the rules of a permutation, with input of permutation on the first list, the output of permutation. If the first list is [1..$n], it is often called twoline form, and the second list would be the word representation.
 $p>cycles([[$a, $b, $c], [$d, $e], [$f, $g]])
 $p>cycles_with_len($n, [[$a, $b, $c], [$d, $e], [$f, $g]])

Initialize $p by the cycle notation. If the length is not specific, the length would be the largest element in the cycles.
 $p>unrank($n, $i)

Initialize $p referring to the lexicological rank of all $npermutations. $i must be between 1 and $n!.
 $p>random($n)

Initialize $p by a randomly selected $npermutation.
DISPLAY THE PERMUTATION
 $p>sprint_wrepr()

Return a string displaying the word representation of $p.
 $p>sprint_tabular()

Return a twoline string displaying the tabular form of $p.
 $p>sprint_cycles()

Return a string with cycles of $p. Onecycles are omitted.
 $p>sprint_cycles_full()

Return a string with cycles of $p. Onecycles are included.
CHECK EQUIVALENCE BETWEEN PERMUTATIONS
CLONE THE PERMUTATION
MODIFY THE PERMUTATION
 $p>swap($i, $j)

Swap the values of $ith position and $jth position.
 $p>comp($q)

Composition of $p and $q, sometimes called multiplication of the permutations. The resultant is $q $p (first do $p, then do $q).
$p and $q must be permutations of same number of elements.
 $p>inverse()

Inverse of $p.
 $p>nxt()

The next permutation under the lexicological order of all $npermutations.
Caveat: may return [].
 $p>prev()

The previous permutation under the lexicological order of all $npermutations.
Caveat: may return [].
PRORERTIES OF THE CURRENT PERMUTATION
 $p>sigma($i)

Return what $i is mapped to under $p.
 $p>rule()

Return the word representation of $p as a list.
 $p>cyc()

Return the cycle representation of $p as a list of list(s).
 $p>elems()

Return the length of $p.
 $p>rank()

Return the lexicological rank of $p. See $p>unrank($n, $i).
 $p>index()

Return the permutation index of $p.
 $p>order()

Return the order of $p, i.e. how many times the permutation acts on itself and return the identity permutation.
 $p>is_even()

Return whether $p is an even permutation. Return 1 or 0.
 $p>is_odd()

Return whether $p is an odd permutation. Return 1 or 0.
 $p>sgn()

Return the signature of $p. Return +1 if $p is even, 1 if $p is odd.
Another view is the determinant of the permutation matrix of $p.
 $p>inversion()

Return the inversion sequence of $p as a list.
 $p>matrix()

Return the permutation matrix of $p.
 $p>fixed_points()

Return the list of fixed points of $p.
METHODS TO BE INPLEMENTED
 sqrt()

Caveat: may return [].
 longest_increasing()
 longest_decreasing()
 coxeter_decomposition()
 comp( more than one permutations )
 reverse()

ref: Chapter 1, Patterns in Permutations and Words
 complement()

ref: Chapter 1, Patterns in Permutations and Words
 is_irreducible()

ref: Chapter 1, Patterns in Permutations and Words
 num_of_occurrences_of_pattern()

ref: Chapter 1, Patterns in Permutations and Words
 contains_pattern()

ref: Chapter 1, Patterns in Permutations and Words
 avoids_pattern()

ref: Chapter 1, Patterns in Permutations and Words
including barred patterns
ref: Section 1.2, Patterns in Permutations and Words
Example: [ 3, 1, 5, 2, 4 ]
AUTHOR
CheokYin Fung, <fungcheokyin at gmail.com>
BUGS
Please report any bugs or feature requests to https://github.com/E78783/MathPermutation/issues.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Math::Permutation
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
CPAN Ratings
Search CPAN
REFERENCES
The module has gained ideas from various sources:
Opensource resources:
General resources:
Algebra, Michael Artin
Patterns in Permutations and Words, Sergey Kitaev
LICENSE AND COPYRIGHT
This software is Copyright (c) 2022 by CheokYin Fung.
This is free software, licensed under:
MIT License