PyTorch torch.matrix_power Function
PyTorch torch Reference Manual
torch.matrix_poweris a function in PyTorch used to compute matrix powers.
Function Definition
torch.matrix_power(input, n)
Usage Example
Example
import torch
# Create a square matrix
A = torch.tensor([[1.0, 2.0], [3.0, 4.0]])
# Compute the 3rd power of the matrix
A_power = torch.matrix_power(A, 3)
print("Matrix power:")
print(A_power)
# Create a square matrix
A = torch.tensor([[1.0, 2.0], [3.0, 4.0]])
# Compute the 3rd power of the matrix
A_power = torch.matrix_power(A, 3)
print("Matrix power:")
print(A_power)
Other Extensions