Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- A = np.array([[2.69, 2.47, 2.07],
- [2.73, 2.39, 1.92],
- [2.93, 2.52, 2.02]])
- b = np.array([[19.37], [19.43], [20.8]])
- def Gaus(A, b):
- n = A.shape[0]
- for i in range(n):
- b[i] /= A[i][i]
- A[i] /= A[i][i]
- for j in range(i + 1, n):
- b[j] -= A[j][i] * b[i]
- A[j] -= A[j][i] * A[i]
- for i in range(n - 1, -1, -1):
- for j in range(i - 1, -1, -1):
- b[j] -= b[i] * A[j][i]
- return b
- ans = Gaus(A.copy(), b.copy())
- print(ans)
Advertisement
Add Comment
Please, Sign In to add comment