# How to define multiple WeylCharacterRings at one time

I am trying to use a script like the one below (to use a simplistic version)

for i in [1..4]:
B"i" = WeylCharacterRing("Bi")


to define multiple Weyl character rings at one time. I then am hoping to go through, and compute the degrees of the representation corresponding to the weight (1,1,1,...,1) depending on which B$i$ I am considering i.e., for $B4$ I would want to calculate

B4(1,1,1,1).degree()


(its $126$). How can I go about automating this in some way? Any tips or reference materials?

edit retag close merge delete

Sort by » oldest newest most voted

You could define a function or use a list comprehension to do this. Both rely on using string formatting to convert integers into strings for the WeylCharacterRing constructor.

Here's an example using list comprehension: I add an empty string '' at the beginning of the list to fix indexing, because lists in Sage are always indexed starting with 0, so you would want B to be the second element in the list, etc.

sage: B = ['']+[WeylCharacterRing("B{0}".format(i)) for i in range(1,5)]
sage: B
The Weyl Character Ring of Type ['B', 1] with Integer Ring coefficients
sage: B(1)
B1(0)
sage: B(1).degree()
1
sage: B(1,1,1,1).degree()
126


And here's a different way you could do this, using a lambda function:

sage: B = lambda i: WeylCharacterRing("B{0}".format(i))
sage: B(2)
The Weyl Character Ring of Type ['B', 2] with Integer Ring coefficients


You can automate lots more things by defining more functions and, if you eventually need to, a new object class!

more

Thanks very much niles, I appreciate these answers. This is perfect for what I'm looking for.

Oh, I think @Volker Braun and I had different ideas about what you were looking for :) Here's another list comprehension which just computes the degrees of various elements (using the lambda function B defined in my other answer):

sage: [B(i)(**i).degree() for i in range(1,5)]
[1, 10, 35, 126]

more

Looks like you want a combination of IntegerVectors and the Python * operator to pass a list as multiple arguments:

sage: B4 = WeylCharacterRing('B4', style='coroots')
sage: l = [1,2,0,1]
sage: B4(*l).degree()
24192

more

So that's how to define a vector....ha I am slowly hacking through the Sage basics. Thanks for the answer @Volker