跳转到主要内容

有限多个正整数的排列

项目描述

Project Status: Active — The project has reached a stable, usable state and is being actively developed. CI Status https://codecov.io/gh/jwodder/permutation/branch/master/graph/badge.svg https://img.shields.io/pypi/pyversions/permutation.svg MIT License

GitHub | PyPI | 文档 | 问题 | 变更日志

排列 为Python中有限多个正整数的排列提供了一个 Permutation 类。支持的操作和属性包括逆元、(群论)阶、奇偶性、组合/乘法、循环分解、循环表示、词表示、莱默码,以及当然,作为整数的可调用对象。

安装

排列 需要 Python 3.7 或更高版本。只需使用 Python 3 的 pip 安装即可(你有 pip 吗?)

python3 -m pip install permutation

示例

>>> from permutation import Permutation
>>> p = Permutation(2, 1, 4, 5, 3)
>>> p.to_cycles()
[(1, 2), (3, 4, 5)]
>>> print(p)
(1 2)(3 4 5)
>>> print(p.inverse())
(1 2)(3 5 4)
>>> p.degree
5
>>> p.order
6
>>> p.is_even
False
>>> p.lehmer(5)
27
>>> q = Permutation.cycle(1,2,3)
>>> print(p * q)
(2 4 5 3)
>>> print(q * p)
(1 3 4 5)
>>> for p in Permutation.group(3):
...     print(p)
...
1
(1 2)
(2 3)
(1 3 2)
(1 2 3)
(1 3)

项目详情


下载文件

下载适用于您平台的文件。如果您不确定该选择哪个,请了解有关安装包的更多信息。

源代码分发

permutation-0.4.0.tar.gz (17.5 kB 查看哈希值)

上传时间 源代码

构建分发

permutation-0.4.0-py3-none-any.whl (9.4 kB 查看哈希值)

上传时间 Python 3

由以下支持