Skip to main content

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

Definition

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:

cycle notation

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:

pq

we can compose them as

compose

Note. composition of permutations is not commutative.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

permualgebra-0.0.1.tar.gz (4.2 kB view hashes)

Uploaded Source

Built Distribution

permualgebra-0.0.1-py3-none-any.whl (17.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page