This repository has been archived on 2020-02-10. You can view files and clone it, but cannot push or open issues or pull requests.
tpmni/5/code.py

13 lines
299 B
Python
Raw Normal View History

2020-02-10 08:54:30 +01:00
#!/usr/bin/env python
import numpy as np
from copy import deepcopy as dp
def gradient_conjugué(A, b, nb=50):
p = dp(b)
r = dp(b)
x = np.zeroes(b.shape)
for i in range(nb):
α = (r.transpose() @ r) / (p.transpose() @ A @ p)
x = x + α @ p
r = r - α @ A @ p