Python中的SymPy Permutation.signature()
Permutation.signature() : signature()是一个sympy Python库函数,它返回将包络的元素按正则顺序排列所需的包络的签名。
签名=(-1)^
语法 : sympy.combinatorics.permutations.Permutation.signature()
返回: permutation的签名。
代码#1:signature()示例
# Python code explaining
# SymPy.Permutation.signature()
# importing SymPy libraries
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.permutations import Permutation
# Using from sympy.combinatorics.permutations.Permutation.signature() method
# creating Permutation
a = Permutation([[2, 0], [3, 1]])
b = Permutation([1, 3, 5, 4, 2, 0])
print ("Permutation a - signature form : ", a.signature())
print ("Permutation b - signature form : ", b.signature())
输出 :
Permutation a – signature form : 1
Permutation b – signature form : -1
代码#2:signature()示例
# Python code explaining
# SymPy.Permutation.signature()
# importing SymPy libraries
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.permutations import Permutation
# Using from
# sympy.combinatorics.permutations.Permutation.signature() method
# creating Permutation
a = Permutation([[2, 4, 0],
[3, 1, 2],
[1, 5, 6]])
print ("Permutation a - signature form : ", a.signature())
输出 :
Permutation a – signature form : 1