dpnp.linalg.inv

dpnp.linalg.inv(a)[source]

Compute the (multiplicative) inverse of a matrix.

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

For full documentation refer to numpy.linalg.inv.

Parameters:

a ((..., M, M) {dpnp.ndarray, usm_ndarray}) -- Matrix to be inverted.

Returns:

out -- (Multiplicative) inverse of the matrix a.

Return type:

(..., M, M) dpnp.ndarray

See also

dpnp.linalg.cond

Compute the condition number of a matrix.

dpnp.linalg.svd

Compute the singular value decomposition.

Examples

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

Inverses of several matrices can be computed at once:

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