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
File details
Details for the file permualgebra-0.0.1.tar.gz
.
File metadata
- Download URL: permualgebra-0.0.1.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05310231b501606aa9b5e3bbd9cb202579dce22b9abd6def1b9285162b98fd5e |
|
MD5 | 2378f28fd5e1c5b1a1e7063f64d0fd33 |
|
BLAKE2b-256 | 7497b8c63d6de6ed49eefebe7603b94d0184bb14b8f05f86fd5f1b67be48d1de |
File details
Details for the file permualgebra-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: permualgebra-0.0.1-py3-none-any.whl
- Upload date:
- Size: 17.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80bb29e8523cc6317f2a8d157c45c3a9227a3e2435fe43ced713629e27684dbd |
|
MD5 | 728d44f3732c6b782e68a541f7a2a030 |
|
BLAKE2b-256 | 909baa898c5100b511e26b3cfa8e885ba329f2115cd71f66964903b1cea8e3e8 |