RuntimeWarning:python中double_scalars中遇到的值无效

时间:2018-03-17 10:24:26

标签: python

我运行此代码但总是收到此错误 -

  

RuntimeWarning:double_scalars中遇到无效值

我无法找到代码中的错误:

from numpy import zeros
def eliminasi_gauss(A,b):
n=len(A)
C=zeros((n,n+1))
for i in range(0,n):
    for j in range(0,n):
        C[i,j]=A[i,j]
    for i in range(0,n):
        C[i,n]=b[i,0]
    for k in range(0,n-1):
        if C[k,k]==0:
            for s in range (0,n+1):
                v=C[k,s]
                u=C[k+1,s]
                C[k,s]=u
                C[k+1,s]=v
        for j in range (k+1,n):
            m=C[j,k]/C[k,k]
            for i in range(0,n+1):
                C[j,i]=C[j,i]-m*C[k,i]
            X = zeros((n,1))
X[n-1,0]=C[n-1,n]/C[n-1,n-1]
for j in range(n-2,-1,-1):
    S=0
    for i in range(j+1,n):
        S=S+C[j,i]*X[i,0]
        X[j,0]=(C[j,n]-S)/C[j,j]
return X

1 个答案:

答案 0 :(得分:0)

我认为你分为零。但是有关更多详细信息,请查看numpy.seterr函数以获取有关RuntimeWarning发生位置的更多信息。