Open In App

Python | sympy partitions.RGS_generalized() method

Last Updated : 27 Aug, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

With the help of sympy.combinatorics.partitions.RGS_generalized() method, we can get the m+1 unrestricted growth string and return a matrix by using sympy.combinatorics.partitions.RGS_generalized() method.

Syntax : sympy.combinatorics.partitions.RGS_generalized(m)
Return : Return a matrix of size m+1.

Example #1 :
In this example we can see that by using sympy.combinatorics.partitions.RGS_generalized() method, we are able to get the unrestricted growth string and return a matrix of size m+1.




# import sympy and RGS_generalized
from sympy.combinatorics.partitions import RGS_generalized
from sympy import *
    
# Using sympy.combinatorics.partitions.RGS_generalized() method
gfg = RGS_generalized(3)
  
print(gfg)


Output :

Matrix(
[ [1, 1, 1, 1],
[1, 2, 3, 0],
[2, 5, 0, 0],
[5, 0, 0, 0] ])

Example #2 :




# import sympy and RGS_generalized
from sympy.combinatorics.partitions import RGS_generalized
from sympy import *
    
# Using sympy.combinatorics.partitions.RGS_generalized() method
gfg = RGS_generalized(6)
  
print(gfg)


Output :

Matrix(
[ [1, 1, 1, 1, 1, 1, 1],
[1, 2, 3, 4, 5, 6, 0],
[2, 5, 10, 17, 26, 0, 0],
[5, 15, 37, 77, 0, 0, 0],
[15, 52, 151, 0, 0, 0, 0],
[52, 203, 0, 0, 0, 0, 0],
[203, 0, 0, 0, 0, 0, 0] ])


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads