0

此代码用于与矩阵一起使用的高斯消除,我不明白为什么屏幕上会出现以下错误。

def elimGauss(A,m,n):
    for k in range(n-1):
        for i in range(k+1,n):
            p = -A[i][k] / (A[k][k])
            for j in range(k,n):
                if (k == j):
                    A[i][j] = 0
                else:
                    A[i][j] = A[i][j] + (p * A[k][j])

错误是:

Traceback (most recent call last):
  File "C:/Users/Solange/Desktop/Trabajo Final Fund. Programacion - Eliminacion Gauss.py", line 42, in <module>
    elimGauss(M,3,3)
  File "C:/Users/Solange/Desktop/Trabajo Final Fund. Programacion - Eliminacion Gauss.py", line 29, in elimGauss
    p = -A[i][k] / (A[k][k])
TypeError: 'NoneType' object is not subscriptable
4

0 回答 0