PyTorch torch.matrix_power function
PyTorch torch reference manual
torch.matrix_power is a function in PyTorch used to compute matrix powers.
Function definition
torch.matrix_power(input, n)
Usage examples
Example
import
torch
Create a square matrix
A
=
torch.
tensor
(
[
[
1.0
,
2.0
]
,
[
3.0
,
4.0
]
]
)
Compute the 3rd power of a matrix
A_power
=
torch.
matrix_power
(
A
,
3
)
(
"Matrix power:"
)
(
A_power
)