jax.numpy.linalg.matrix_power

Contents

jax.numpy.linalg.matrix_power#

jax.numpy.linalg.matrix_power(a, n)[source]#

Raise a square matrix to the (integer) power n.

LAX-backend implementation of numpy.linalg.matrix_power().

Original docstring below.

For positive integers n, the power is computed by repeated matrix squarings and matrix multiplications. If n == 0, the identity matrix of the same shape as M is returned. If n < 0, the inverse is computed and then raised to the abs(n).

Note

Stacks of object matrices are not currently supported.

Parameters:
  • a ((..., M, M) array_like) – Matrix to be “powered”.

  • n (int) – The exponent can be any integer or long integer, positive, negative, or zero.

Returns:

a**n – The return value is the same shape and type as M; if the exponent is positive or zero then the type of the elements is the same as those of M. If the exponent is negative the elements are floating-point.

Return type:

(…, M, M) ndarray or matrix object