My intention with this program was to get a 4x4 matrix with certain values, but for some reason the loop is putting everything into the same row/column... What is off about my code?
def matrixH0(k):
H0=[]
print H0
for m in range (0,k):
for n in range (0,k):
if abs(m-n)==1:
H0.append(math.sqrt(n+m+1)/2.)
else:
H0.append(0)
print H0
This is my output:
[0,
0.7071067811865476,
0,
0,
0.7071067811865476,
0,
1.0,
0,
0,
1.0,
0,
1.224744871391589,
0,
0,
1.224744871391589,
0]