0

I used to perform Cholesky/LU decompostion to solve linear problem with Eigen but now I have to solve an Linear homogeneous system (the right hand side of my linear system is the null vector). I have to do an Gaussian reduction on my square Matrix in order to find a space of solution, but I can not find any gaussian reduction algorithm on Eigen's documentation. So Is this any Gaussian reduction algorithm on Eigen ?

Benzait Sofiane
  • 107
  • 1
  • 12
  • Not sure what you exactly you are asking. LU decomposition is the same as Gaussian reduction. If your matrix is rank-deficiant, make sure to use a pivoting decomposition. – chtz Aug 05 '21 at 20:40

1 Answers1

3

If you have the eigen decomposition of the coefficient matrix A, the solution for the homogeneous system will be any vector that can be written as a linear combination of eigenvectors associated with eigenvalue 0.

The function eig gives you the eigen decomposition of a matrix. Numerical errors will result in the eigenvectors not being exact so you simply choose the eigenvector with smallest magnitude, and you solve the least squares problem this way.

So your problem boils down to

w, v = np.linalg.eig(A)
x = v[:,np.argmin(abs(v))]

Then A @ x is approximately the null vector.

Bob
  • 13,867
  • 1
  • 5
  • 27
  • Thank you for your response, so it mean that if my matrix have no eigenvalue 0 the only solution is the null vector ? – Benzait Sofiane Aug 16 '21 at 07:29
  • Yes, that's right, usually the condition stated is that the coefficient matrix has determinant zero, but remember that the determinant is the product of the eigenvalues. So if, and only if, all eigenvalues are non-zero the determinant is non-zero. – Bob Aug 16 '21 at 10:17