私が直面している問題は、それe
が行減算の正しい答えであることですが、 が設定されている場合はではなく にa[j] = e
なりa[j]
ます。[0,0,0]
[0,0.5,0.5]
import numpy as np
def naive_gauss(a,b):
n = len(a)
for i in range(n-1):
for j in range(i+1, n):
print("a is: ,",a,"\n")
factor = a[j][i] / a[i][i]
e = a[j] - (a[i] * factor)
print("e is", e)
print("a[j] is: ,", a[j], "\n")
a[j] = e
print("a[j] is:, ", a[j])
print("-----------------------------------")
b[j] = b[j] - (b[i] * factor)
print("new a is: ", a)
print("new b is: ", b, "\n")
print("new matrix is:", a)
return b
d = np.array([8,-11,-3])
f = np.array([[2,1,-1],[-3,-1,2],[-2,1,2]])
print(naive_gauss(f,d))