import numpy as np with open(\'matrix.txt\', \'r\') as f: x = [] for line in f: x.append(map(int, line.split())) f.close() a = array(x) l, v = eig
exponent is a 1D array. This means that exponent[0] is a scalar, and exponent[0][i] is trying to access it as if it were an array.
exponent
exponent[0]
exponent[0][i]
Did you mean to say:
L = identity(len(l)) for i in xrange(len(l)): L[i][i] = exponent[i]
or even
L = diag(exponent)
?