To obtain the matrix inverse, use linalg.pinv()
instead of linalg.inv()
documentation de linalg.pinv: https://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.pinv.html documentation de linalg.inv: https://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.inv.html Autre Réf: https://www.quora.com/What-is-the-difference-between-pinv-and-inv#:~:text=What%20is%20the%20difference%20between%20pinv%20and%20inv%3F,-ad%20b&text=pinv()%20function%20in%20OCTAVE,be%20an%20m*n%20matrix.
--Le vecteur propre est renvoyé verticalement sous forme de matrice avec la fonction linalg.eig.
When using eigval, eigvec = scipy.linalg.eig()
, the returned eigenvectors are in the columns of eigvec
.
Supposing we want the first eigenvalue & eigenvector pair of a matrix my_matrix
,
import scipy.linalg as la
eigval, eigvec = la.eig(my_matrix)
then we need
eigval_pair1 = eigval[0]
eigvec_pair1 = eigvec[:,0]
and NOT
eigvec_pair1 = eigvec[0]
Recommended Posts