This is a pre-release version (latest).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy latest / scipy / sparse / linalg / _matfuncs / inv

function

scipy.sparse.linalg._matfuncs:inv

source: build-install/usr/lib/python3.14/site-packages/scipy/sparse/linalg/_matfuncs.py:31

Signature

def inv(A)

Summary

Compute the inverse of a sparse arrays.

Parameters

A : (M, M) sparse arrays

square matrix to be inverted

Returns

Ainv : (M, M) sparse arrays

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_array
from scipy.sparse.linalg import inv
A = csc_array([[1., 0.], [1., 2.]])
Ainv = inv(A)
✓
Ainv
A.dot(Ainv)
A.dot(Ainv).toarray()
✗
array([[1., 0.],
       [0., 1.]])
.. versionadded:: 0.12.0

Aliases

  • scipy.sparse.linalg.inv