0

I am trying to calculate the inverse of a matrix in c++ using Eigen. The inverse calculated is wrong, as I tried multiplying the original matrix with its inverse and I did not get the Identity matrix. I also checked if the matrix is singular by calculating its determinant, but that was not 0. The matrix is a dynamic-size matrix of doubles, which gets filled with values inside a function. In the code it looks like this: Eigen::MatrixXd inverse_ee = knotenadmittanzmatrix_ee.inverse();

I added pictures of the matrix "knotenadmittanzmatrix_ee" (Knotenadmittanz Extern-Extern), and the inverse I get (Knotenadmittanz Extern-Extern invertiert). enter image description here

enter image description here

Can anyone help me with this problem?

Claire
  • 29
  • 1
  • 1
  • 4
  • 2
    It looks like the determinant of your matrix is 0, indeed. Isn't it strange that the full matrix is filled with the same value? That might be the origin of your problem. – BNilsou Feb 08 '21 at 09:28
  • What do you mean by *not the identity matrix* ? How much does it differ from it? – Damien Feb 08 '21 at 09:29
  • No, the matrix with alle the same value is the "inverted" one. – Claire Feb 08 '21 at 12:14
  • When I multiply the matrix with its "inverse", the outcome has a row with numbers around -20. That is what I meant with not the identity matrix. – Claire Feb 08 '21 at 12:15
  • Can you print the determinant of the original matrix? – Marc Glisse Feb 08 '21 at 13:25
  • Determinant is 7.2e-08 – Claire Feb 08 '21 at 13:59
  • 1
    `7.2e-8` is essentially zero compared to the scale of your matrix. You can try to compute a pseudo inverse, if that helps. (N.B.: Please post your matrix as text not as an image, in case somebody wants to try this locally). – chtz Feb 08 '21 at 16:56
  • Does this answer your question? [Eigen is Failing to Give Correct Matrix Inverse (c++)](https://stackoverflow.com/questions/22059268/eigen-is-failing-to-give-correct-matrix-inverse-c) – chtz Feb 09 '21 at 09:04

0 Answers0