Raise a square matrix to the (integer) power n.
For positive integers n, the power is computed by repeated matrix squarings and matrix multiplications. If n=0, the identity matrix of the same type as M is returned. If n<0, the inverse is computed and raised to the exponent.
Parameters: | M : array_like
n : integer
|
---|---|
Returns: | M to the power n :
|
Raises: | LinAlgException :
|
See also
The, operator.
Examples
>>> np.linalg.matrix_power(np.array([[0,1],[-1,0]]),10)
array([[-1, 0],
[ 0, -1]])