Commit 853d49d3 authored by KANTAPONG SONG-NGAM's avatar KANTAPONG SONG-NGAM

work

parent 5925d4d6
def Ab2Uc(A,b):
import numpy as np
A = np.array(A, float)
b = np.array(b, float)
n = len(b)
for i in range(0, n - 1):
for j in range(i + 1, n):
lam = A[j, i] / A[i, i]
A[j, i] = 0
A[j, i + 1:n] = A[j, i + 1:n] - lam * A[i, i + 1:n]
b[j] = b[j] - lam * b[i]
U = A.copy()
c = b.copy()
print('U : ',U)
print('C : ',c)
b = [11,-16,17]
A =[[4, -2, 1],[-2, 4, -2],[1, -2, 4]]
Ab2Uc(A,b)
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