我一直在处理这段代码,我收到以下错误

时间:2016-04-12 19:47:04

标签: python-3.x gauss

此代码适用于使用矩阵的高斯消除,我无法理解屏幕上出现以下错误的原因。

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

0 个答案:

没有答案