Commit 0b901981 authored by rungrurdee wandee's avatar rungrurdee wandee

add

parent e63bf3f7
def single_prec(v):
return (-1)**int(v[0])*sum([int(v[i])*2**(8-i) for i in range(1,23)])
def double_prec(v):
def double_prec(v):
return (-1)**int(v[0])*sum([int(v[i])*2**(11-i) for i in range(1,23)])
def IEEE(v):
return (-1)^2 * 2^(e-1023) * 1.f
import numpy as np
def upperTriSol(A, b):
n = np.size(b)
x = np.zeros_like(b)
x[-1] = 1. / A[-1, -1] * b[-1]
for i in xrange(n-2, -1, -1):
x[i] = 1. / A[i, i] * (b[i] - np.sum(A[i, i+1:] * x[i+1:]))
return x
......@@ -2,4 +2,18 @@ def ge(A, b):
pass
def solve(A, b):
pass
import numpy.linalg
result = numpy.linalg.solve(A,b)
for i,x in zip(1,range(len(result)+1),result):
print('$x_{} = {}'.format(i,x))
m,n,_ = map(int,input().split('x'))
print(m, n)
A= []
for row in range(m):
A.append(list(map(int,input().split(','))))
#solve(A,b)
print(n,_)
b=list(map(int,input().split(',')))
solve(A,b)
เขียนฟังก์ชันเพื่อหา upper-triangular matrix (U) จากสมการ Ax = b
โดยเขียนฟังก์ชัน Ux = c เป็นสมการที่ลดรูปแล้ว
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