Python SymPy Permutation.ascents()方法

Python SymPy Permutation.ascents()方法

Permutation.ascents() : ascents()是一个sympy Python库函数,用于返回permutation中ascents的位置。
上升是指a[i]< a[i+1]的元素。

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

返回:在排列组合中的上升位置

代码 #1 : ascents() 示例

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

输出 :

Permutation a – ascents form : [0, 2]
Permutation b – ascents form : [0, 1]

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

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

输出 :

Permutation a – ascents form : [1, 2, 4]

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程