📜  Python| SymPy Permutation.commutator() 方法

📅  最后修改于: 2022-05-13 01:54:23.053000             🧑  作者: Mango

Python| SymPy Permutation.commutator() 方法

Permutation.commutator() : commutator()是一个 sympy Python库函数,它返回分区的换向器。假设'a' 和'b' 是'C' 的一部分,那么a 和b 的交换子是'C' 恒等式当且仅当a 和b 可交换,即ab == ba。

代码 #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))

输出 :

代码 #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))

输出 :