mindspore.ops.matrix_solve

View Source On Gitee
mindspore.ops.matrix_solve(matrix, rhs, adjoint=False)[source]

Solves systems of linear equations.

matrix[...,M,M]x[...,M,K]=rhs[...,M,K]adjoint(matrix[...,M,M])x[...,M,K]=rhs[...,M,K]

Warning

On GPU, if the matrix is irreversible, an error may be reported or an unknown result may be returned.

Parameters
  • matrix (Tensor) – The first input tensor.

  • rhs (Tensor) – The second input tensor.

  • adjoint (bool, optional) – Indicating whether to solve with matrix or its (block-wise) adjoint. Default False .

Returns

Tensor

Supported Platforms:

Ascend CPU

Examples

>>> import mindspore
>>> matrix = mindspore.tensor([[5., 4.], [3., 1.]])
>>> rhs = mindspore.tensor([[7.], [2.]])
>>> result = mindspore.ops.matrix_solve(matrix, rhs)
>>> print(result)
[[0.14285707]
 [1.5714287 ]]