I have a PETSc
Mat and would like to estimate its condition number.
For small matrices, the condition number can be reliably computed using the singular value decomposition. Do a
For larger matrices, you can estimate the condition number using a Krylov method. For example, the Arnoldi iteration performed by GMRES incrementally computes a Hessenberg decomposition. The extremal singular values and eigenvalues of the Hessenberg matrix are good approximations to those of the original matrix. To have PETSc estimate eigenvalues this way, run with
These options say to estimate the extremal singular values on each Krylov iteration. GMRES is used to compute the Krylov space (you could also use CG) with a huge restart. At restarts, GMRES discards the current Krylov space, so all the progress on singular value estimates is lost in a restart. The final option
This will generally be accurate for the largest singular values, but may overestimate the smallest singular value unless the method has converged. If you have a solver for the matrix (e.g. using
Use SLEPc if you need more accurate estimates of the smallest singular value (and for all other eigenvalue and singular value problems).