SymPy Python中的Permutation.transpositions()。

SymPy Python中的Permutation.transpositions()。

Permutation.transpositions() : transpositions()是一个Sympy Python库函数,它返回分解为一列转置的包络。我们总是可以将一个包络表达为转置的乘积。

语法 : sympy.combinatorics.permutations.Permutation.transpositions()

返回:被分解成转置列表的互换法

代码 #1 : transpositions() 示例

# Python code explaining
# SymPy.Permutation.transpositions()
  
# importing SymPy libraries
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.permutations import Permutation
  
# Using from 
# sympy.combinatorics.permutations.Permutation.transpositions() method 
  
# creating Permutation
a = Permutation([[2, 0], [3, 1]])
  
b = Permutation([1, 3, 5, 4, 2, 0])
  
  
print ("Permutation a - transpositions form : ", a.transpositions())
print ("Permutation b - transpositions form : ", b.transpositions())

输出 :

Permutation a – transpositions form : [(0, 2), (1, 3)]
Permutation b – transpositions form : [(0, 5), (0, 2), (0, 4), (0, 3), (0, 1)]

代码 #2 : transpositions() 示例

# Python code explaining
# SymPy.Permutation.transpositions()
  
# importing SymPy libraries
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.permutations import Permutation
  
# Using from 
# sympy.combinatorics.permutations.Permutation.transpositions() method 
  
# creating Permutation
a = Permutation([[2, 4, 0], 
                 [3, 1, 2],
                 [1, 5, 6]])
  
  
print ("Permutation a - transpositions form : ", a.transpositions())

输出 :

Permutation a – transpositions form : [(0, 4), (0, 2), (0, 1), (0, 6), (0, 5), (0, 3)]

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程