What does it mean to have an index to scalar variable error? python

前端 未结 3 550
长情又很酷
长情又很酷 2021-01-03 18:03
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         


        
3条回答
  •  暖寄归人
    2021-01-03 18:46

    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.

    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)
    

    ?

提交回复
热议问题