Commit 8dbf9242 authored by Kittipong Maneewong's avatar Kittipong Maneewong

ส่งงาน week06

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