2021-06-11 09:52:16 +0100 received badge ● Famous Question (source) 2021-01-21 15:32:53 +0100 received badge ● Popular Question (source) 2020-06-20 15:50:06 +0100 received badge ● Notable Question (source) 2020-06-20 15:50:06 +0100 received badge ● Popular Question (source) 2020-04-21 16:17:10 +0100 received badge ● Popular Question (source) 2017-07-07 22:18:23 +0100 received badge ● Popular Question (source) 2014-06-29 18:55:40 +0100 received badge ● Popular Question (source) 2014-06-29 18:55:40 +0100 received badge ● Notable Question (source) 2014-06-29 18:55:40 +0100 received badge ● Famous Question (source) 2014-06-29 03:15:40 +0100 marked best answer Pulling the index of an entry of a matrix Let $M$ be some matrix, then I am looking for how to find out which entries of $M$ make the statement M[i,j] == 25 true. Specifically, this is the code I'm using to generate the matrix, called deg: deg = matrix(ZZ, 15) A = lambda i: WeylCharacterRing("A{0}".format(i), style = "coroots") for i in range(1,15): fw = A(i).fundamental_weights() for j in range(1,len(fw)): deg[i,j] = A(i)(fw[j]).degree() print deg  It works great, but now instead of printing deg and finding the entries manually, I would like to be able to store which entries [i,j] of deg are equal to 25 in some list, and then print that list, which would ideally look something like: list(tfentry) { (2,3), (4,4) }  etc. Any tips on where to look or help files to examine? Thanks very much. 2014-06-29 03:15:40 +0100 marked best answer Assigning individual entries of a matrix I have been using code as follows to compute fundamental weight representations of Lie groups inside $GL(25)$:  D = lambda i: WeylCharacterRing("D{0}".format(i), style = "coroots") for i in range(2,12): fw = D(i).fundamental_weights() deg = D(i)(fw[1]).degree() print deg  But now I am interested in going through and looking at all D(i)(fw[j]).degree() for i in range(1,12), j in range(1,len(fw)) Now this will be quite a set of numbers, so I am wondering how I can pick out the ones that give me 25 and then store the index of that matrix. Right now I have this: import numpy deg = numpy.zeros(12) D = lambda i: WeylCharacterRing("D{0}".format(i), style = "coroots") for i in range(2,12): fw = D(i).fundamental_weights() for j in range(1,len(fw)): deg[i,j] = D(i)(fw[j]).degree() print deg  But this doesn't work. Is my syntax off? 2014-06-29 03:15:40 +0100 marked best answer 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? Thanks for your time. 2014-06-29 03:15:40 +0100 marked best answer How to find instances where $d(a,b) = p^2$ for $p$ a prime Suppose I have a dimension formula (for a Lie algebra representation) given by $\mathrm{dim}_{a,b} = {(a+1)(b+1)(a+b+2) \over 2}$. I now would like to find pairs $(a,b)$ where $\dim_{a,b} = p^2$ for $p$ a prime? What are some techniques for accomplishing this? Should I first filter out a list of primes using isprime and then check possible pairs $(a,b)$ for each prime $p < N$, say $1000$. 2013-06-17 16:02:36 +0100 asked a question How to see the documentation for a Sage function I am looking for the documentation (i.e., the source code) of invariant_degree() in the Weyl Character Rings module. I have looked through that website pretty extensively, but I think I am looking in the wrong place? 2013-06-13 11:57:57 +0100 asked a question Generating permutations of coefficients I have created the following function to return all pairs (n, k) such that a slightly altered binomial coefficient is less than or equal to a certain N: bin = lambda n, k : binomial(n + k - 1, k) def nkfilter(N): pairs = [] for n in range(2, N+1): for k in range(1, n): if bin(n, k) <= N: pairs.append([n, k]) print '\n (n, k)\n' return pairs  This prints out the following: example = nkfilter(8); print example (n, k) [[2, 1], [3, 1], [3, 2], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1]]  I now would like to take this n and generate a tuple of length n: (a_1,..., a_n), for which all the a_is are less than or equal to k. I have been considering permutations to accomplish this, but I believe I need to first generate list_of_numbers_less_than_k and then take permutations(n, list_of_numbers). However I am not sure which data types to use, and how to generate these n-length tuples. 2013-06-11 12:17:39 +0100 marked best answer How to compute an iterated product in Sage You can use the prod() function (see prod? for some help): sage: f = lambda n, k, i : prod([binomial(n+k-l,k) for l in range(1,i+1)]) sage: f(3,4,2) 75  This also works symbolically: sage: var('n,k') (n, k) sage: f(n,k,2) binomial(k + n - 2, k)*binomial(k + n - 1, k)  2013-06-10 17:58:24 +0100 asked a question How to compute an iterated product in Sage I am wondering about how to define a function f(n, k, i) that will take inputs n, k, i and give me the following product: $$\prod_{\ell = 1}^i {n + k - \ell \choose k}$$ So for $i = 2$, this would look like ${n + k - 1 \choose k}\cdot {n + k - 2 \choose k}$. Would I use a for loop to iteratively add to the product until all i terms were accounted for? 2013-06-03 16:26:23 +0100 commented answer Unsure why the 0 values error keeps coming up I see, I just corrected the range that the function needs to access and it worked perfectly. Thanks! 2013-06-03 16:25:55 +0100 marked best answer Unsure why the 0 values error keeps coming up The problem comes from how you called your function. The function returns an empty list, but you try to assign two variables (fname and cname) with that output. A simpler example: sage: def my_empty_func(): sage: return [] sage: a,b = my_empty_func() ... ValueError: need more than 0 values to unpack  Here, the error means that you need the function my_empty_func() to return a list (or tuple) of two elements to feed a and b, but it returned a list of zero elements. 2013-06-03 16:18:10 +0100 commented question Unsure why the 0 values error keeps coming up @vdelecroix I'm sorry, I was missing a + and I put the return statement that appears halfway down in order to see if the first output of my function was valid but I suppose this is not a correct debugging technique. I have edited the code to fix those two mistakes 2013-06-03 16:15:20 +0100 received badge ● Editor (source) 2013-06-03 14:06:38 +0100 asked a question Unsure why the 0 values error keeps coming up I am trying to code an algorithm to find the degrees of all small rank representations of $A_n$ that are equal to $p^2$ for some prime $p$. However, I think that my code should be correct, but it keeps giving me the following error: Traceback (most recent call last): File "", line 1, in File "_sage_input_24.py", line 10, in exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("W2ZuYW1lLCBjbmFtZV0gPSBBX2NvbWIycmVwKDMp"),globals())+"\\n"); execfile(os.path.abspath("___code___.py")) File "", line 1, in File "/tmp/tmp2u4eia/___code___.py", line 3, in exec compile(u'[fname, cname] = A_comb2rep(_sage_const_3 ) File "", line 1, in ValueError: need more than 0 values to unpack  The code for which it gives me this error is the following: 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(bound): # now onto combinations of two of the fws ##### for k in fw: fw = A(i+1).fundamental_weights() 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  A helpful answer would be one that answers: What does ValueError: need more than 0 values to unpack mean and where should I look for tips on how to fix it. Many thanks for your time. 2013-06-03 14:00:42 +0100 commented answer How to store outputs from a function for later use Many thanks @tmontneil, I now understand. Partition is indeed useful to keep in mind 2013-05-31 11:51:47 +0100 commented answer How to store outputs from a function for later use @tmontneil but will the w[i] values now feed into a Schur function? I thought they had to be lists i.e., I think I need w[0] = [1,0,...,0] right? 2013-05-31 11:19:15 +0100 commented question How to store outputs from a function for later use Just figured out part of it: [index, deg, L] = rankrep(3) 2013-05-31 11:19:15 +0100 received badge ● Commentator 2013-05-31 11:15:08 +0100 asked a question How to store outputs from a function for later use My function that I have written to compute the rank of fundamental representations is as follows: # given a prime p, return all A_n representations of dimension = p^2 def rankrep(p): bound = p*p s = SymmetricFunctions(QQ).schur() Sym_p = s[p] A = lambda i: WeylCharacterRing("A{0}".format(i)) deg = [] index = [] L = [] for i in xrange(bound): deg.append([]) fw = A(i+1).fundamental_weights() temp = A(i+1) for j in fw.keys(): deg[i].append(temp(fw[j]).degree()) if temp(fw[j]).degree() == bound: index.append('A'+str(i+1)+'(fw['+str(j)+'])') L.append(fw[j]) return index, deg  But now if I call rankrep it does not let me store index or deg, it just prints them. I am wanting to also store the L variable I create as these are the weights that give me the desired dimension, and convert from these weights, which make up the highest weight $Lambda = a_1 \omega_1 + \cdots + a_n \omega_n$ (here $Lambda$ is the high weight, $\omega_i$ are the fundamental weights). The $\omega_i$ have the form $(1,1,\dots,1,0, \dots, 0)$, and I would like to express my high weight as $(a_1 + \cdots + a_{n-1}, a_2 + \cdots + a_{n-1}, \dots, a_{n-1},0)$. However, since I am only considering one of the $a_i$ nonzero, this vector will look like $(a_i, a_i, \dots, a_i, 0, \dots, 0)$. I would like to store this vector, and then pass it as a partition to a schur function s that I define in the code. How can I store these outputs and format them (i.e., data types, lists, dictionaries, vectors) so that I can then alter them as described and apply my schur function? 2013-05-31 06:49:19 +0100 marked best answer Pulling the index of an entry of a matrix One way you could do this is to use a conditional list comprehension; these take the form [x for x in list if ]  And since you will be iterating over a matrix, a double list comprehension is in order; these take the form [x for b in a for x in b]  where a is the "outer list", and b is the "inner list". And since you want to know the indices and the entries together, we'll use the enumerate function. So here's a conditional double list comprehension which returns (i,j) such that deg(i,j) == 15: sage: [(i,j) for (i,deg_i) in enumerate(deg) for (j,deg_ij) in enumerate(deg_i) if deg_ij == 15] [(5, 2), (5, 4), (14, 1)]  Another Sage-specific data type that might interest you is sets -- these are like lists, but automatically condense duplicate entries. For example, the set of values in the matrix deg can be given by sage: deg_values = set([x for row in deg for x in row]) sage: len(deg_values) 52  2013-05-30 17:18:01 +0100 commented answer Problem getting indices to sync up Thanks very much @John for your help 2013-05-30 17:17:50 +0100 marked best answer Problem getting indices to sync up Try replacing  for j in range(len(fw)):  with  for j in fw.keys():  (In your code, fw is not a list, but a finite family, so its entries are not indexed by 0, 1, 2, ..., necessarily.) 2013-05-30 14:46:19 +0100 commented question Problem getting indices to sync up I've added this line of code  [(i,j) for (i,deg_i) in enumerate(deg) for (j,deg_ij) in enumerate(deg_i) if deg_ij == p**2] to pull the indices 2013-05-30 14:37:25 +0100 asked a question Problem getting indices to sync up I'm not sure what is wrong with the following code: # given a prime p, return all A_n representations of dimension = p^2 def rankrep(p): bound = p**2 A = lambda i: WeylCharacterRing("A{0}".format(i), style = "coroots") deg = [] for i in xrange(bound): deg.append([]) fw = A(i+1).fundamental_weights() temp = A(i+1) for j in range(len(fw)): deg[i].append(temp(fw[j]).degree()) return deg  But when I run it, it is unable to return anything, and tells me Keyval Error 0. Should I not be using append here? I eventually hope to insert some if trees testing whether a given temp(fw[j].degree() == p**2, but I'm not sure how to pull those indices either. Any help would be greatly appreciated. Regards. 2013-05-30 13:50:46 +0100 marked best answer Plethysym as composition of functions I don't know the answer to this question, but you may be able to determine it yourself by looking at the source code for plethysm. You can do this with .plethysm??, as in sage: Sym = SymmetricFunctions(QQ) sage: s = Sym.schur() sage: s2 = s[2] sage: s2.plethysm??  Also (I apologize if you've already checked this) the Wikipedia page on plethysm is very short, but includes a cryptic comment which may help you decide if your guess is correct or not. Good luck! 2013-05-29 18:03:57 +0100 asked a question Plethysym as composition of functions On this page the plethysym function is described as "composition of functions". Is this implying that writing s[2](s[lambda]) for some other partition $\lambda$ is like taking the symmetric square of the schur function corresponding to $\lambda$?