Matrix_power
Source:R/gen-namespace-docs.R, R/gen-namespace-examples.R, R/gen-namespace.R
torch_matrix_power.RdMatrix_power
matrix_power(input, n) -> Tensor
Returns the matrix raised to the power n for square matrices.
For batch of matrices, each individual matrix is raised to the power n.
If n is negative, then the inverse of the matrix (if invertible) is
raised to the power n. For a batch of matrices, the batched inverse
(if invertible) is raised to the power n. If n is 0, then an identity matrix
is returned.
Examples
if (torch_is_installed()) {
a = torch_randn(c(2, 2, 2))
a
torch_matrix_power(a, 3)
}
#> torch_tensor
#> (1,.,.) =
#> 0.2480 -0.4916
#> 0.0807 0.0885
#>
#> (2,.,.) =
#> 0.3373 -1.7682
#> 1.7426 -0.5897
#> [ CPUFloatType{2,2,2} ]