mindspore.ops.matrix_exp

mindspore.ops.matrix_exp(x)[source]

Computes the matrix exponential of a square matrix. Supports batched inputs.

\[matrix\_exp(x) = \sum_{k=0}^{\infty} \frac{1}{k !} x^{k} \in \mathbb{K}^{n \times n}\]
Parameters

x (Tensor) – The shape of tensor is \((*, n, n)\) where * is zero or more batch dimensions. Must be one of the following types: float16, float32, float64, complex64, complex128.

Returns

Tensor, has the same shape and dtype as the x.

Raises
  • TypeError – If x is not a Tensor.

  • TypeError – If the dtype of x is not one of the following dtype: float16, float32, float64, complex64, complex128.

  • ValueError – If the rank of x is less than 2.

  • ValueError – If the last two dimensions of x are not equal.

Supported Platforms:

CPU

Examples

>>> x = Tensor(np.array([[1, 2], [0, 1]]), mindspore.float32)
>>> output = ops.matrix_exp(x)
>>> print(output)
[[2.7182817 5.436563 ]
[0.        2.7182817]]