What I have: I have a list List123=[-13,3,12,1]and a 2-by-4-matrix Matrix123=numpy.zeros((2,4), dtype=Decimal).
I want: I want to change all entries of the matrix to any entry in the list, and then print it on the terminal. There are 4 ^ (2 * 4) = 65536 possible combinations. I want to print each combination.
How am I doing it now: Here is my current code:
List123=[-13,3,12,1]
Matrix123=numpy.zeros((2,4), dtype=Decimal)
k=0
for k in List123:
Matrix123[0,0]=k
for k in List123:
Matrix123[0,1]=k
for k in List123:
Matrix123[0,2]=k
for k in List123:
Matrix123[0,3]=k
for k in List123:
Matrix123[1,0]=k
for k in List123:
Matrix123[1,1]=k
for k in List123:
Matrix123[1,2]=k
for k in List123:
Matrix123[1,3]=k
print Matrix123
print " "
My question is: What is a more compact way to write this in just a few lines of code? I need to do the same for a 23 by 27 matrix. That would mean I have to write the code for 23 * 27 = 621 for-loops manually if I don't find a more compact way.