SymPy | Python中的 Permutation.rank_trotterjohnson()
Permutation.rank_trotterjohnson() :rank_trotterjohnson()是一个 sympy Python库函数,它返回非字典排列的 trotter johnson 秩。
Syntax : sympy.combinatorics.permutations.Permutation.rank_trotterjohnson()
Return : next permutation in lexicographical rank_trotterjohnson
代码 #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() 示例– 2D 排列
# 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