Python中的SymPy Permutation.rank_nonlex()

Python中的SymPy Permutation.rank_nonlex()

Permutation.rank_nonlex() : rank_nonlex()是一个Sympy Python库函数,用于返回非词法互换的等级。

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

返回:非词典式排列法的等级。

代码 #1 : rank_nonlex() 示例

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

输出 :

Permutation a – rank_nonlex form : 13
Permutation b – rank_nonlex form : 72

代码 #2 : rank_nonlex() 例子 – 二维互换

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

输出 :

Permutation a – rank_nonlex form : 218

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程

SymPy 教程