Advertisement
Guest User

Untitled

a guest
Nov 29th, 2024
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | Source Code | 0 0
  1. from itertools import combinations
  2.  
  3. def level(M):
  4.     return M.denominator() # not documented enough :(
  5.  
  6. def create_matrix(CT):
  7.     AS = RootSystem(CT).ambient_space()
  8.     return Matrix([[r.associated_coroot().inner_product(v) for r in AS.positive_roots()] for v in AS.fundamental_weights()])
  9.  
  10. def calculate_levels(CT):
  11.     M = create_matrix(CT)
  12.     allrows = list(range(M.nrows()))
  13.     res = dict()
  14.     print(binomial(M.ncols(), M.nrows()))
  15.     # for cols in Subsets(range(M.ncols()), M.nrows()): # much slower?
  16.     for cols in combinations(range(M.ncols()), M.nrows()):
  17.         res[cols]=0
  18.         try:
  19.             sM = M[allrows, cols].inverse()
  20.             res[cols] = level(sM)
  21.         except:
  22.             res[cols] = 0            
  23.     return res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement