我运行此代码但总是收到此错误 -
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