Python| SymPy Permutation.commutator() 方法
Permutation.commutator() : commutator()是一个 sympy Python库函数,它返回分区的换向器。假设'a' 和'b' 是'C' 的一部分,那么a 和b 的交换子是'C' 恒等式当且仅当a 和b 可交换,即ab == ba。
Syntax :
sympy.combinatorics.permutations.Permutation.commutator()
Return :
commutator of the partition
代码 #1:commutator() 示例
# Python code explaining
# SymPy.Permutation.commutator()
# importing SymPy libraries
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.permutations import Permutation
# Using from sympy.combinatorics.permutations.Permutation.commutator() method
# creating Permutation
a = Permutation([2, 0, 3, 1, 5, 4])
b = Permutation([1, 3, 5, 4, 2, 0])
print ("Permutation a - commutator form : ", a.commutator(b))
print ("Permutation b - commutator form : ", b.commutator(a))
输出 :
Permutation a – commutator form : Permutation([3, 1, 2, 5, 4, 0])
Permutation b – commutator form : Permutation([5, 1, 2, 0, 4, 3])
代码 #2 : commutator() 示例– 自换向器
# Python code explaining
# SymPy.Permutation.commutator()
# importing SymPy libraries
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.permutations import Permutation
# Using from sympy.combinatorics.permutations.Permutation.commutator() method
# creating Permutation
a = Permutation([[2, 4, 0],
[3, 1, 2],
[1, 5, 6]])
# SELF COMMUTATING
print ("Permutation a - commutator form : ", a.commutator(a))
输出 :
Permutation a – commutator form : Permutation([], size=7)