Commit 3ffe0728 authored by Aruchira's avatar Aruchira

Up

parent d7cf96bd
def ge(A, b):
# 1. elimination
n = len(b)
for j in range(0, n-1): # pivot equation
#print('------------\nj = %d'%(j))
for i in range(j+1, n):
lam = A[i,j]/A[j,j]
A[i,j:n] = A[i, j:n] - lam*A[j, j:n]
b[i] = b[i] - lam*b[j]
#print(A)
#print(b)
#print()
# 2. back substitution
x = b.copy()
for k in range(n-1, -1, -1):
x[k] = (b[k] - np.dot(A[k,k+1:n], x[k+1:n]))/A[k,k]
print(x)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment