# 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?

edit retag close merge delete

Just figured out part of it: [index, deg, L] = rankrep(3)

( 2013-05-31 11:19:15 +0200 )edit

Sort by » oldest newest most voted

I am not sure to understand your request, but you can modify the last line of your function to return L as well by:

return index, deg, L


And then play with it:

sage: index, deg, L = rankrep(3)
sage: index
['A8(fw[1])', 'A8(fw[8])']
sage: deg
[[2],
[3, 3],
[4, 6, 4],
[5, 10, 10, 5],
[6, 15, 20, 15, 6],
[7, 21, 35, 35, 21, 7],
[8, 28, 56, 70, 56, 28, 8],
[9, 36, 84, 126, 126, 84, 36, 9],
[10, 45, 120, 210, 252, 210, 120, 45, 10]]
sage: deg[3]
[5, 10, 10, 5]
sage: L
[(1, 0, 0, 0, 0, 0, 0, 0, 0), (1, 1, 1, 1, 1, 1, 1, 1, 0)]


To transform the elements of L to a list of vectors, you can:

sage: w = [i.to_vector() for i in L]
sage: w[0]
(1, 0, 0, 0, 0, 0, 0, 0, 0)
sage: w[1]
(1, 1, 1, 1, 1, 1, 1, 1, 0)

more

@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:51:47 +0200 )edit
1

As i defined them, they are vectors: sage: w[1].parent() Vector space of dimension 9 over Rational Fiel You can make them partitions: sage: Partition(w[1]) [1, 1, 1, 1, 1, 1, 1, 1] and perhaps sage: s = SymmetricFunctions(QQ).schur() sage: s(Partition(w[1])) s[1, 1, 1, 1, 1, 1, 1, 1] If you prefer lists, you can: sage: w[1].list() [1, 1, 1, 1, 1, 1, 1, 1, 0] But it seems it leads to the same things: sage: s(w[1].list()) == s(Partition(w[1])) True Of course, you can do everything in one step: sage: w = [i.to_vector().list() for i in L] sage: [s(i) for i in w] [s[1], s[1, 1, 1, 1, 1, 1, 1, 1]] By the way, i am not expert in Symmetric functions at all, just guessing what your needs are.

( 2013-05-31 12:19:24 +0200 )edit

Many thanks @tmontneil, I now understand. Partition is indeed useful to keep in mind

( 2013-06-03 14:00:42 +0200 )edit