File Exchange

image thumbnail

sparseinv: sparse inverse subset

version 1.2 (9 KB) by Tim Davis
Computes a subset of inv(A) for a real sparse matrix A, using Takahashi's equations.


Updated 20 Nov 2014

View License

inv(A) is often abused by MATLAB users, but there are times when you need to compute selected entries of inv(A).
The sparseinv function computes the sparse inverse subset of a sparse matrix A. These entries in the inverse subset correspond to nonzero entries in the factorization of A. They can be computed without computing all of the entries in inv(A), so this method is much faster and takes much less memory than inv(A). If A is symmetric and positive definite, then all entries of the diagonal of inv(A) are computed (as well as many off-diagonal terms). This version is restricted to real sparse matrices. A complex version is left for future work.

Example (err will be small):

load west0479
A = west0479 ;
[Z, Zpattern] = sparseinv (A) ;
S = inv (A) ;
err = norm (Zpattern .* (Z - S), 1) / norm (S, 1)

Cite As

Tim Davis (2020). sparseinv: sparse inverse subset (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (5)

I'm curious, if instead of:
[L,U,P,Q] = lu(A);
the following code is executed:
[L,U,P,Q,Sc] = lu(A) ;
Sc = diag(Sc);
[row, col] = find(P');
idx = col(row);
Sc = Sc(idx);
Sc = 1./full(Sc);
U = U ./ Sc;
L = (L' .* Sc)' ./ Sc;

The result will be sparser because the row-scaling LU factorization leads to a sparser structure.

Haining Pan

Thanks for sharing! I am working with complex sparse matrix, thus I am curious that which part I should modify. Would you please share some thought on how sparseinv_mex.c works?

Great submission! It's (almost) exactly what I was looking for. Is there a way to perform low-rank updates of the inverse subset (e.g. like cholupdate)?



Converted to a toolbox.

minor fix to sparseinv.m for sparse symmetric positive definite matrices.

MATLAB Release Compatibility
Created with R2011b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags