SymPy中的Permutation.rank_trotterjohnson()

SymPy中的Permutation.rank_trotterjohnson()

Permutation.rank_trotterjohnson() : rank_trotterjohnson()是一个sympy Python库函数,用于返回非词法排列的trotter johnson等级。

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

返回:在lexicographical rank_trotterjohnson中的下一个permutation。

代码 #1 : rank_trotterjohnson() 示例

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

输出 :

Permutation a – rank_trotterjohnson form : 10
Permutation b – rank_trotterjohnson form : 555

代码#2:rank_trotterjohnson()示例–二维排布

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

输出 :

Permutation a – rank_trotterjohnson form : 2420

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程

SymPy 教程