本文整理匯總了Python中permutation.Permutation.fromCycles方法的典型用法代碼示例。如果您正苦於以下問題:Python Permutation.fromCycles方法的具體用法?Python Permutation.fromCycles怎麽用?Python Permutation.fromCycles使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類permutation.Permutation
的用法示例。
在下文中一共展示了Permutation.fromCycles方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: data
# 需要導入模塊: from permutation import Permutation [as 別名]
# 或者: from permutation.Permutation import fromCycles [as 別名]
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""This program displays the group data (as calculated by ``groups.about``) for
a group generated from a list of permutations specified on the command line.
Each permutation must be written as a sequence of cycles separated by ``/``,
where each cycle is a sequence of positive integers separated by ``,``. For
example, the command:
symdata.py 1,2/3,4 3,4,5
displays the data for the group generated by ``(1 2)(3 4)`` and ``(3 4
5)``."""
import sys
sys.path.insert(1, sys.path[0] + '/..')
from groups import Symmetric
from groups.about import about, printAbout
from permutation import Permutation
if len(sys.argv) < 2:
sys.stderr.write("Usage: %s permutation ...\n" % (sys.argv[0],))
sys.exit(2)
perms = [Permutation.fromCycles(map(int, b.split(',')) for b in a.split('/'))
for a in sys.argv[1:]]
perms.sort()
data = about(Symmetric(perms[-1].degree).generate(perms))
data["name"] = '⟨' + ', '.join(map(str, perms)) + '⟩'
printAbout(data)
print