Python中的SymPy Partition.RGS_enum()
Partition.RGS_enum() 。RGS_enum()是一个sympy Python库函数,它计算了一个大小为n的超集可能出现的限制性增长字符串(字符串中a[i]是元素i出现的区块)的总数。
限制性增长字符串–字符串中的每个字符,a i导致相应元素所属的块(B i)。
语法 : sympy.combinatorics.partitions.Partition.RGS_enum()
返回:限制性增长字符串的总数,可能是大小为n的超集。
代码 #1 : RGS_enum() 示例
# Python code explaining
# SymPy.RGS_enum()
# importing SymPy libraries
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.partitions import RGS_enum
# Using from sympy.combinatorics.partitions.Partition.RGS_enum() method
p = RGS_enum(4)
q = RGS_enum(9)
print ("no. of strings possible for size 4: ", p)
print ("no. of strings possible for size 9: ", q)
输出 :
no. of strings possible for size 4: 15
no. of strings possible for size 9: 203
代码 #2 :RGS_enum()示例
# Python code explaining
# SymPy.RGS_enum()
# importing SymPy libraries
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.partitions import RGS_enum
# Using from sympy.combinatorics.partitions.Partition.RGS_enum() method
p = RGS_enum(20)
q = RGS_enum(-1)
print ("no. of strings possible for size 20 ", p)
print ("no. of strings possible for size -1: ", q)
输出 :
no. of strings possible for size 20 51724158235372
no. of strings possible for size -1: 0