à la recherche de la définition des matrices définies positives
This commit is contained in:
parent
6af0f377d3
commit
ccea71af3d
19
5/code.py
19
5/code.py
@ -2,7 +2,14 @@
|
||||
import numpy as np
|
||||
from copy import deepcopy as dp
|
||||
|
||||
def gradient_conjugué(A, b, nb=50):
|
||||
"""
|
||||
TP final MNI
|
||||
auteurs: Cyril Colin
|
||||
Dylan Voisin
|
||||
date: 10/02/2020
|
||||
"""
|
||||
|
||||
def gradient_conjugué(A: np.ndarray, b: np.ndarray, nb=50):
|
||||
p = dp(b)
|
||||
r = dp(b)
|
||||
x = np.zeroes(b.shape)
|
||||
@ -10,3 +17,13 @@ def gradient_conjugué(A, b, nb=50):
|
||||
α = (r.transpose() @ r) / (p.transpose() @ A @ p)
|
||||
x = x + α @ p
|
||||
r = r - α @ A @ p
|
||||
β = (r.transpose() @ r) / (r.transpose() @ r)
|
||||
p = r + β @ p
|
||||
return x
|
||||
|
||||
if __name__ == '__main__':
|
||||
A = np.array(
|
||||
[
|
||||
[2, 3, 4]
|
||||
]
|
||||
)
|
@ -4,3 +4,6 @@ On cherche x tq A.x=b
|
||||
A matrice p×p symétrique définie positive (donc inversible)
|
||||
|
||||
On cherche à résoudre cette équation (les t dans la formule c'est la transposée)
|
||||
|
||||
jean.sequeira@univ-amu.fr
|
||||
TPfinal_<Nom>.py
|
Reference in New Issue
Block a user