Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Your code is very close. Try a modification to your list comprehension to get what you are looking for.

S=[X*Y for X in M for Y in M]

I'm not clear on your last question. Can you give an example?

Your code is very close. Try a modification to your list comprehension to get what you are looking for.

S=[X*Y for X in M for Y in M]

I'm not clear on For your last question. Can you give an example?question, one approach is:

s=range(4)
q=Permutations(s,3)
print len(q)
print q
a = matrix(ZZ,[[1,0],[0,1]])
b = matrix(ZZ,[[0,1],[1,0]])
c = matrix(ZZ,[[1,1],[0,1]])
d = matrix(ZZ,[[0,1],[0,1]])
M=[a,b,c,d]
S=[prod([M[i] for i in list(p)]) for p in q]
print S