Re: inverse of singular sparse matrix

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: inverse of singular sparse matrix

Rik-4
On 05/10/2019 01:07 AM, [hidden email] wrote:
Subject:
What should the inverse of a singular sparse matrix be?
From:
Marco Caliari [hidden email]
Date:
05/10/2019 01:07 AM
To:
[hidden email] [hidden email]
List-Post:
[hidden email]
Precedence:
list
MIME-Version:
1.0
Message-ID:
[hidden email]
Content-Type:
multipart/alternative; boundary="_000_PR1PR01MB5017C5B102796F53924F3D1C9E0C0PR1PR01MB5017eurp_"
Message:
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.



I like the idea of splitting the special case of an empty matrix (probably a mistake, and, in any case, no useful value to return) from the more general singular matrix.

For the general singular matrix, I think preserving the sparsity but replacing all non-zero values with Inf is the most similar behavior to the dense case.  As such, it satisfies the principle of least astonishment (https://en.wikipedia.org/wiki/Principle_of_least_astonishment) in user interface design.

Looks good to me.

--Rik
Reply | Threaded
Open this post in threaded view
|

Re: inverse of singular sparse matrix

nrjank


On Fri, May 10, 2019, 4:54 PM Rik <[hidden email]> wrote:
On 05/10/2019 01:07 AM, [hidden email] wrote:

Matlab returns, in most cases, a *full* matrix with +/- Inf and/or NaN. Not clear to find a pattern. 


I'm happy to run a series of test cases on MATLAB if it's important to tease out compatible behavior.