scipy.sparse.linalg.
inv#
- scipy.sparse.linalg.inv(A)[source]#
Compute the inverse of a sparse matrix
- Parameters:
- A(M, M) sparse matrix
square matrix to be inverted
- Returns:
- Ainv(M, M) sparse matrix
inverse of A
Notes
This computes the sparse inverse of A. If the inverse of A is expected to be non-sparse, it will likely be faster to convert A to dense and use
scipy.linalg.inv
.Examples
>>> from scipy.sparse import csc_matrix >>> from scipy.sparse.linalg import inv >>> A = csc_matrix([[1., 0.], [1., 2.]]) >>> Ainv = inv(A) >>> Ainv <Compressed Sparse Column sparse matrix of dtype 'float64' with 3 stored elements and shape (2, 2)> >>> A.dot(Ainv) <Compressed Sparse Column sparse matrix of dtype 'float64' with 2 stored elements and shape (2, 2)> >>> A.dot(Ainv).toarray() array([[ 1., 0.], [ 0., 1.]])
Added in version 0.12.0.