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