222
This commit is contained in:
6
69-5.py
6
69-5.py
@@ -1,6 +1,7 @@
|
||||
x = [0,1,2,3]
|
||||
y = [0,0,0,0]
|
||||
|
||||
# 追赶法
|
||||
def ZGsolve(A,b):
|
||||
n = len(b)
|
||||
beta = [0]*n
|
||||
@@ -21,19 +22,21 @@ def ZGsolve(A,b):
|
||||
|
||||
return b
|
||||
|
||||
|
||||
# 获取相邻点的差分
|
||||
def GetDList(list_r):
|
||||
result = []
|
||||
for i in range(1,len(list_r)):
|
||||
result.append(list_r[i] - list_r[i-1])
|
||||
return result
|
||||
|
||||
# 获取相邻点的差商
|
||||
def GetDQList(list_x, list_y):
|
||||
result = []
|
||||
for i in range(1,len(list_y)):
|
||||
result.append((list_y[i] - list_y[i-1]) / (list_x[i] - list_x[i-1]))
|
||||
return result
|
||||
|
||||
# 三次样条插值
|
||||
def CubicSplineInterpolation(list_x,list_y,boundary_type,a1,a2):
|
||||
list_h = GetDList(list_x)
|
||||
list_dqxy = GetDQList(list_x, list_y)
|
||||
@@ -68,6 +71,7 @@ def CubicSplineInterpolation(list_x,list_y,boundary_type,a1,a2):
|
||||
|
||||
return M,list_h
|
||||
|
||||
# 打印矩阵
|
||||
def PrintResult(M,list_h,list_x,list_y):
|
||||
for i in range(len(list_h)):
|
||||
k1 = (M[i+1]-M[i])/6/list_h[i]
|
||||
|
||||
Reference in New Issue
Block a user