fn
matrix_power
→Tensormatrix_power(x: Tensor, n: int)Raise a square matrix to an integer power.
Computes for an integer exponent :
Parameters
xTensorSquare matrix of shape
(*, m, m).nintInteger exponent. Negative values require to be
invertible.
Returns
Tensor, shape (*, m, m).
Notes
Uses binary exponentiation (repeated squaring) so the cost is
matrix multiplies rather than .
Implemented as a Python composite over matmul and
inv so autograd flows naturally — the engine
matrix_power_op is not differentiable.
Examples
>>> import lucid
>>> from lucid.linalg import matrix_power
>>> A = lucid.tensor([[1.0, 1.0], [0.0, 1.0]])
>>> matrix_power(A, 5)
Tensor([[1.0000, 5.0000],
[0.0000, 1.0000]])