1
$\begingroup$

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?

$\endgroup$
  • 1
    $\begingroup$ You can make a check. Is A * inv(A) = 1? If this is not the case (within numerical precision) then your inverse is obviously wrong. $\endgroup$ – Henri Menke Aug 8 '17 at 21:43
  • $\begingroup$ is U(2,2) exactly 0 or something $\approx u$ $\endgroup$ – M.K. aka Grisu Aug 9 '17 at 10:50
  • $\begingroup$ I would like to know for every case, without having to multiply the matrices, but I can do that. Thanks! $\endgroup$ – N Luis Aug 9 '17 at 14:21
  • $\begingroup$ I haven't checked if U(2,2) is actually zero. But, per definition of ZGETRF, when INFO > 0, U(INFO,INFO) = 0... $\endgroup$ – N Luis Aug 9 '17 at 14:22
  • 1
    $\begingroup$ if $U(2,2) = 0$ (exactly, as a return value INFO=2 would indicate), then the original matrix is singular so ZGETRI should fail (with the same error INFO=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$ – GoHokies Aug 9 '17 at 19:06
0
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.