Learn R Programming

GPUmatrix (version 1.0.2)

matrix_ranges: Get different statistics for a gpu.matrix-class.

Description

Functions to summarise different values of a gpu.matrix-class object by rows or columns. Specifically: the maximum value, the index of the maximum value, the minimum value, the index of the minimum value, the mean, the variance, the sum of the values and the rank of the values.

These functions mimic the corresponding function of 'base', 'matrixStats' and 'Matrix' libraries.

Usage

# S4 method for gpu.matrix.tensorflow
rowMaxs(x)
# S4 method for gpu.matrix.torch
rowMaxs(x)
# S4 method for gpu.matrix.tensorflow
colMaxs(x)
# S4 method for gpu.matrix.torch
colMaxs(x)
# S4 method for gpu.matrix.tensorflow
max(x)
# S4 method for gpu.matrix.torch
max(x)

# S4 method for gpu.matrix.tensorflow rowMins(x) # S4 method for gpu.matrix.torch rowMins(x) # S4 method for gpu.matrix.tensorflow colMins(x) # S4 method for gpu.matrix.torch colMins(x) # S4 method for gpu.matrix.tensorflow min(x) # S4 method for gpu.matrix.torch min(x)

# S4 method for gpu.matrix.tensorflow rowMeans(x) # S4 method for gpu.matrix.torch rowMeans(x) # S4 method for gpu.matrix.tensorflow colMeans(x) # S4 method for gpu.matrix.torch colMeans(x) # S4 method for gpu.matrix.tensorflow mean(x) # S4 method for gpu.matrix.torch mean(x)

# S4 method for gpu.matrix.tensorflow rowVars(x) # S4 method for gpu.matrix.torch rowVars(x) # S4 method for gpu.matrix.tensorflow colVars(x) # S4 method for gpu.matrix.torch colVars(x)

# S4 method for gpu.matrix.tensorflow rowRanks(x) # S4 method for gpu.matrix.torch rowRanks(x) # S4 method for gpu.matrix.tensorflow colRanks(x) # S4 method for gpu.matrix.torch colRanks(x)

# S4 method for gpu.matrix.tensorflow rowSums(x) # S4 method for gpu.matrix.torch rowSums(x) # S4 method for gpu.matrix.tensorflow colSums(x) # S4 method for gpu.matrix.torch colSums(x) # S4 method for gpu.matrix.tensorflow sum(x) # S4 method for gpu.matrix.torch sum(x)

Value

max, rowMaxs, colMaxs calculate the maximum value of a gpu.matrix-class object, of each row and of each column respectively. which.max determines the location of the maximum value.

min, rowMins, colMins calculate the minimum value of a gpu.matrix-class object, of each row and of each column respectively. which.min determines the location of the minimum value.

mean, rowMeans, colMeans calculate the mean (average) value of a gpu.matrix-class object, of each row and of each column respectively.

rowVars, colVars calculate the variance of each row and of each column of a gpu.matrix-class object respectively.

rowRanks, colRanks: given a gpu.matrix-class object, these functions return a gpu.matrix which rearranges each row and each column into ascending respectively.

rowSums, colSums, sum sum the value of a a gpu.matrix-class object, of each row and of each column respectively.

Arguments

x

a gpu.matrix.

Details

The value returned by almost each function is a numeric vector stored in the CPU. Only the function rowRanks, colRanks, and sum return a gpu.matrix-class object.

These functions internally calls the corresponding function of the library torch or tensorflow (depending on the type of input gpu.matrix-class). 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

For more information:

rowMaxs, colMaxs, max, which.max, and torch_max.

rowMins, colMins, min, which.min, and torch_min.

rowMeans, colMeans, mean, and torch_mean.

rowVars, colVars, and torch_var.

rowRanks, colRanks, and torch_argsort.

rowSums, colSums, sum, and torch_sum.

Examples

Run this code
# \donttest{
if (FALSE) {
a <- gpu.matrix(rnorm(9),3,3)

#the maximum value of a:
max(a)

#maximum of value in each row of a:
rowMaxs(a)

#maximum value in each column of a:
colMaxs(a)

#index of the maximum value of a:
which.max(a)

#minimum value of a:
min(a)

#minimum value in each row of a:
rowMins(a)

#minimum value in each column of a:
colMins(a)

#index of the minimum value in a:
which.min(a)

#mean of a:
mean(a)

#mean of each row of a:
rowMeans(a)

#mean of each column of a:
colMeans(a)

#variance of each row of a:
rowVars(a)

#variance of each column of a:
colVars(a)

#sum of all values of a:
sum(a)

#sum of each fow of a:
rowSums(a)

#sum of each column of a:
colSums(a)

#ranking of each row of a:
rowRanks(a)

#ranking of each columna of a:
colRanks(a)
}
# }

Run the code above in your browser using DataLab