I am computing the inverse of a complex matrix. I execute ZGETRF but U(2,2) = 0. When I compute ZGETRI, the inverse is determined. Can I trust this inverse?
1 Answer
I have answered a similar question when a failed zgetrf
will be followed by a successful zgetrs
. In this question, the situation is similar.
To call zgetri
, you have to call zgetrf
first. Therefore, if zgetrf
failed (in a sense that $U_{2,2}=0$) in the first place, there is no point in calling zgetri
and hope for a reliable result.
Why zgetri
does not result in an explicit error itself is another question, and probably will depend on the particular implementation of LAPACK/BLAS library. But, to sum it up, since you got an error in the first step of your two-step process of obtaining the inverse of the matrix, you certainly cannot trust the obtained inverse.
The strategy how to understand what is actually happening with the matrix is discussed in the aforementioned question but boils down to the analysis of the spectrum of your matrix, its singular values, and condition numbers, followed by the investigation of the physics where you matrix is coming from originally.
Since you are interested in the inverse of the matrix (as you noted in the comments) and your matrices are "problematic", I would suggest using an SVD-route process to obtain the inverse as opposed to LU-route. It is slower; however, you will be able to see how the singular values behave in the first place and identify problems earlier and see them explicitly.
A * inv(A) = 1
? If this is not the case (within numerical precision) then your inverse is obviously wrong. $\endgroup$INFO=2
would indicate), then the original matrix is singular soZGETRI
should fail (with the same errorINFO=2
). Not directly related to your original question, but may I ask why you want to compute the explicit inverse of your matrix operator? $\endgroup$