Calculate the permutations with Python.
Project description
Permualgebra
This package allows user to do permutations calculation in terms of Modern Algebra.
Install
pip install permualgebra
Permutation
Definition
Let S be a set of n distinct elements. A permutation of S is a bijection
For example, let S = {1, 2, 3, 4, 5, 6}, define
i | 1 | 2 | 3 | 4 | 5 | 6 |
---|---|---|---|---|---|---|
p(i) | 6 | 3 | 2 | 4 | 5 | 1 |
Or a permutation can be written in cycle notation, where we often omit the 1-cycles:
this cycle notation is also the way that this package express a permutation.
The length of a cycle is the number of elements of S in that cycle.
The length of a permutation is the number of cycles in that permutation.
Theorem
Every permutation on S = {1, ..., n} can be written as a product of disjoint cycles. i.e. no elements of S is repeated in the cycle description.
import permualgebra as pm
p = pm.Permutation(["3 6 4 2", "1 3 4 6", "5 2 1 3"])
print(p) # (3 6 4 2)(1 3 4 6)(5 2 1 3)
pSimplify = p.getSimplify()
print(pSimplify)# (1 2 6)(3 5)
p.simplify()
print(p) # (1 2 6)(3 5)
Suppose we have 2 permutations:
we can compose them as
Note. composition of permutations is not commutative.
This package implements the composition of permutation as multiplication.
import permualgebra as pm
p = pm.Permutation(["1 5", "2 4 6"])
q = pm.Permutation(["1 3 5 4", "2 6"])
p.simplify()
q.simplify()
print((p*q).getSimplify()) # (1 3)(4 5 6)
print((q*p).getSimplify()) # (1 4 2)(3 5)
To Do
- Errors and Exceptions
- More detailed wiki and documentation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for permualgebra-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80bb29e8523cc6317f2a8d157c45c3a9227a3e2435fe43ced713629e27684dbd |
|
MD5 | 728d44f3732c6b782e68a541f7a2a030 |
|
BLAKE2b-256 | 909baa898c5100b511e26b3cfa8e885ba329f2115cd71f66964903b1cea8e3e8 |