当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python Sympy Partition.prev_lex()用法及代码示例


Partition.prev_lex():prev_lex()是一个sympy Python库函数,按字典顺序返回前一个整数分区n。如果分区为[1,…,1],则此顺序环绕[n]。

用法: sympy.combinatorics.partitions.Partition.prev_lex()

返回:前一个整数分区,按字母顺序排列n


代码1:prev_lex()示例

] 
  
# Python code explaining 
# SymPy.prev_lex() 
  
# importing SymPy libraries 
from sympy.combinatorics.partitions import Partition 
from sympy.combinatorics.partitions import IntegerPartition 
  
# Using from sympy.combinatorics.partitions.Partition.prev_lex() method  
p = IntegerPartition([312, 121, 14, 5]) 
  
print('p : ', p) 
print('\nPrevious Integrer : ', p.prev_lex())

输出:

p : [312, 121, 14, 5]

Previous Integrer : [312, 121, 14, 4, 1]

代码2:prev_lex()示例

] 
  
# Python code explaining 
# SymPy.prev_lex() 
  
# importing SymPy libraries 
from sympy.combinatorics.partitions import Partition 
from sympy.combinatorics.partitions import IntegerPartition 
  
# Using from sympy.combinatorics.partitions.Partition.prev_lex() method  
p = IntegerPartition([1, 312, 121, 14,  
                      34, 56, 32]) 
  
print('p : ', p) 
print('\nPrevious Integrer : ', p.prev_lex())

输出:

p : [312, 121, 56, 34, 32, 14, 1]

Previous Integrer : [312, 121, 56, 34, 32, 13, 2]



相关用法


注:本文由纯净天空筛选整理自noobestars101大神的英文原创作品 SymPy | Partition.prev_lex() in Python。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。