Advertisement
little_meow3

Решение методом Гаусса

May 18th, 2022
456
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def solve_lu(L, U, ans):
  2.     n = L.shape[0]
  3.     y = np.matrix(np.zeros([n, 1]))
  4.     for i in range(n):
  5.         y[i, 0] = ans[i, 0] - L[i, :i] * y[:i]
  6.  
  7.     x = np.matrix(np.zeros([n, 1]))
  8.     for i in range(1, n + 1):
  9.         x[-i, 0] = (y[-i] - U[-i, -i:] * x[-i:, 0]) / U[-i, -i]
  10.     return x
Advertisement
RAW Paste Data Copied
Advertisement