numpy 1.22.4 Pypi GitHub Homepage
Other Docs
NotesParametersRaisesReturnsBackRef
inv(a)

Given a square matrix a, return the matrix :None:None:`ainv` satisfying dot(a, ainv) = dot(ainv, a) = eye(a.shape[0]) .

Notes

versionadded

Broadcasting rules apply, see the numpy.linalg documentation for details.

Parameters

a : (..., M, M) array_like

Matrix to be inverted.

Raises

LinAlgError

If a is not square or inversion fails.

Returns

ainv : (..., M, M) ndarray or matrix

(Multiplicative) inverse of the matrix a.

Compute the (multiplicative) inverse of a matrix.

See Also

scipy.linalg.inv

Similar function in SciPy.

Examples

>>> from numpy.linalg import inv
... a = np.array([[1., 2.], [3., 4.]])
... ainv = inv(a)
... np.allclose(np.dot(a, ainv), np.eye(2)) True
>>> np.allclose(np.dot(ainv, a), np.eye(2))
True

If a is a matrix object, then the return value is a matrix as well:

>>> ainv = inv(np.matrix(a))
... ainv matrix([[-2. , 1. ], [ 1.5, -0.5]])

Inverses of several matrices can be computed at once:

>>> a = np.array([[[1., 2.], [3., 4.]], [[1, 3], [3, 5]]])
... inv(a) array([[[-2. , 1. ], [ 1.5 , -0.5 ]], [[-1.25, 0.75], [ 0.75, -0.25]]])
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

scipy.linalg._matfuncs.tanhm scipy.linalg._matfuncs.coshm scipy.linalg._matfuncs.sinhm scipy.linalg._matfuncs.tanm numpy.matrixlib.defmatrix.matrix.I

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /numpy/linalg/linalg.py#476
type: <class 'function'>
Commit: