mindspore.mint.linalg.inv

View Source On Gitee
mindspore.mint.linalg.inv(input)[source]

Compute the inverse of the input matrix.

Parameters

input (Tensor) – A matrix to be calculated. Input input must be at least two dimensions, and the size of the last two dimensions must be the same size. And the matrix must be invertible.

Returns

Tensor, has the same type and shape as input input.

Raises
  • ValueError – If the size of the last two dimensions of input is not the same.

  • ValueError – If input is not empty and its dimensions are less than 2.

  • ValueError – If the dimensions of input are larger than 6.

Supported Platforms:

Ascend

Examples

>>> from mindspore import Tensor, mint
>>> from mindspore import dtype as mstype
>>> x = Tensor([[1., 2.], [3., 4.]], mstype.float32)
>>> print(mint.linalg.inv(x))
[[-2.   1. ]
 [ 1.5 -0.5]]