Taking 3 or more combinations using `combinations`

Question:

The following is a bit of code I wrote in Sage to compute the dimensions of certain Lie algebras that are equal to $p^2$ for some $p$.

def A_comb2rep(p):
    bound = p*p
    name_fund = []
    name_comb = []
    A = lambda i: WeylCharacterRing("A{0}".format(i))
    for i in range(bound):
        for k in range(1,bound+1):
            fw = A(i+1).fundamental_weights()
            if A(i+1)(k * fw[1]).degree() > bound:
                break
            else:
                for v in fw:
                    if A(i+1)(k * v).degree() == bound:
                        name_fund.append([])
                        name_fund[len(name_fund)-1].append('A'+str(i+1)+'('+str(k)+'*'+str(v)+')')
    for i in range(1,bound): # now onto combinations of two of the fws   #####
        fw = A(i+1).fundamental_weights()
        for k in fw:
            if A(i+1)(fw[1] + fw[2]).degree() > bound:
                break
            else:
                for j in fw:
                    rep = A(i+1)(j+k)
                    deg = rep.degree()
                    if deg == bound:
                        name_comb.append([])
                        name_comb[len(name_comb)-1].append('A'+str(i+1)+'['+str(j)+'+'+str(k)+']')
    return name_comb, name_fund

The second half of the code is where I consider combinations of two fundamental weights. I am now wondering how to extend this for combinations of 3 or more fundamental weights using the combination function in the iterables module.

More specifically, how would I code in a sum of 3 of the elements of fw? I know that v = combinations(fw, 3) would then put into v all ${n choose 3}$ triple combinations, but the elements of fw are tuples, like (1,1,1,0,0,0). How would I then sum each of the triples I get in v? I apologize if this question is inappropriate for this site.

Asked By: Moderat

||

Answers:

I’m not good at math, but if the question is “How would I then sum each of the triples I get in v?” then the answer is:

sv = map(sum, v)

where sv will contain a list (an iterator actually) of sums of triples from v

Answered By: zaquest
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.