What should the inverse of a singular sparse matrix be?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

What should the inverse of a singular sparse matrix be?

Marco Caliari-4

Dear maintainers,


it was recently fixed a nasty segmentation fault while trying to invert a sparse singular matrix


https://savannah.gnu.org/bugs/?56232


The question now is: what should the result of inv (A) be, with A a sparse singular matrix?

Current behavior:

A is a full singular matrix: both Octave and Matlab return inv (A) as a full matrix of the same dimension of A with Inf as elements, that is Inf (size (A)), plus a warning.

A is a sparse singular matrix: Matlab returns, in most cases, a *full* matrix with +/- Inf and/or NaN. Not clear to find a pattern. Octave returns a "division by zero" error.


My proposal, for A sparse singular, is to return a matrix with the same sparsity pattern of A, with Inf as elements, plus a warning. This solution has the advantage to not return a full useless matrix for a sparse singular input. The drawback is that the inverse of the sparse null matrix would be the input itself. In this specific case, I propose to turn the warning to a dedicated error. Additionally, I propose to extend this last behavior to the full null case. I cannot imagine a situation in which a user wants to invert the null matrix, except for a coding mistake.


Other opinions or comments are welcome.


Marco