Python中的SymPy Permutation.order()
Permutation.order() : order()是一个sympy Python库函数,用于计算一个排列组合的顺序。当排列组合被提升到其顺序的幂,那么,在这种情况下,顺序就等于相同的排列组合。
语法 : sympy.combinatorics.permutations.Permutation.order()
返回:排列组合的顺序
代码 #1 : order() 示例
# Python code explaining
# SymPy.Permutation.order()
# importing SymPy libraries
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.permutations import Permutation
# Using from sympy.combinatorics.permutations.Permutation.order() method
# creating Permutation
a = Permutation([[2, 0], [3, 1]])
b = Permutation([1, 3, 5, 4, 2, 0])
print ("Permutation a - order form : ", a.order())
print ("Permutation b - order form : ", b.order())
输出 :
Permutation a – order form : 2
Permutation b – order form : 6
代码#2:order()示例–二维互换法
# Python code explaining
# SymPy.Permutation.order()
# importing SymPy libraries
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.permutations import Permutation
# Using from sympy.combinatorics.permutations.Permutation.order() method
# creating Permutation
a = Permutation([[2, 4, 0],
[3, 1, 2],
[1, 5, 6]])
print ("Permutation a - order form : ", a.order())
输出 :
Permutation a – order form : 7