torch.matrix_power
-
torch.matrix_power(input, n) → Tensor -
Returns the matrix raised to the power
nfor square matrices. For batch of matrices, each individual matrix is raised to the powern.If
nis negative, then the inverse of the matrix (if invertible) is raised to the powern. For a batch of matrices, the batched inverse (if invertible) is raised to the powern. Ifnis 0, then an identity matrix is returned.Example:
>>> a = torch.randn(2, 2, 2) >>> a tensor([[[-1.9975, -1.9610], [ 0.9592, -2.3364]], [[-1.2534, -1.3429], [ 0.4153, -1.4664]]]) >>> torch.matrix_power(a, 3) tensor([[[ 3.9392, -23.9916], [ 11.7357, -0.2070]], [[ 0.2468, -6.7168], [ 2.0774, -0.8187]]])
© 2019 Torch Contributors
Licensed under the 3-clause BSD License.
https://pytorch.org/docs/1.8.0/generated/torch.matrix_power.html