Learn R Programming

GPUmatrix (version 1.0.2)

power_of_a_matrix: Compute the kth power of a matrix.

Description

Comput the kth power of a squere matrix, i.e., multiply the gpu.matrix-class object by itself as many times as user indicates.

Usage

# S4 method for gpu.matrix.tensorflow,numeric
%^%(x, k)
# S4 method for gpu.matrix.torch,numeric
%^%(x, k)

Value

the nth power of the input gpu.matrix-class object. The returned matrix is also a gpu.matrix-class object.

Arguments

x

a gpu.matrix.

k

the power of the matrix.

Details

The input x gpu.matrix-class needs to be squere. This function internally call the method %*% as many times as required. If the input gpu.matrix-class object is stored on the GPU, then the operations will be performed on the GPU. See gpu.matrix.

See Also

See also: %*%.

Examples

Run this code
# \donttest{
if (FALSE) {

a <- gpu.matrix(rnorm(9),nrow=3,ncol=3)
a %^% 5


}
# }

Run the code above in your browser using DataLab