13 lines
299 B
Python
13 lines
299 B
Python
#!/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
|