Exemple de factorisation de Cholesky avec python et scipy en reprenant l'example de wikipedia:
>>> import numpy as np>>> A = np.array(([1,1,1,1],[1,5,5,5],[1,5,14,14],[1,5,14,15]))>>> Aarray([[ 1, 1, 1, 1],[ 1, 5, 5, 5],[ 1, 5, 14, 14],[ 1, 5, 14, 15]])>>> L = linalg.cholesky(A, lower=True)>>> Larray([[ 1., 0., 0., 0.],[ 1., 2., 0., 0.],[ 1., 2., 3., 0.],[ 1., 2., 3., 1.]])>>> L.transpose()array([[ 1., 1., 1., 1.],[ 0., 2., 2., 2.],[ 0., 0., 3., 3.],[ 0., 0., 0., 1.]])
Vérification si on retrouve bien la matrice de départ:
>>> dot(L,L.transpose())array([[ 1., 1., 1., 1.],[ 1., 5., 5., 5.],[ 1., 5., 14., 14.],[ 1., 5., 14., 15.]])
Recherches associées
| Liens | Site |
|---|---|
| scipy.linalg.cholesky | scipy doc |
| Factorisation de Cholesky | wikipedia |
| numpy.ndarray.transpose | scipy doc |
