| dist {GPUmatrix} | R Documentation |
Distance Matrix Computation with GPU
Description
This function mimics the 'stats' function dist: 'computes and returns the distance matrix computed by using the specified distance measure to compute the distances between the rows of a data matrix.'
Usage
dist(x, method = "euclidean", diag = FALSE,
upper = FALSE, p = 2)
## S4 method for signature 'gpu.matrix.torch'
dist(x,method,diag,upper,p)
Arguments
x |
a |
method |
the same as the 'stats' function |
diag |
the same as the 'stats' function |
upper |
the same as the 'stats' function |
p |
the same as the 'stats' function |
Details
The function mimics the 'stat' function dist. The distance measures used are (taken from dist):
euclidean: \sqrt{\sum_i(x_i-y_i)^2}
maximum: Maximum distance between two components of x and y.
manhattan: Absolute distance between the tow vectors.
minkowski: the p norm: the ppth root of the sum of the ppth powers of the differences of the components.
For more details see dist.
The function dist 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.
Value
The function returns a gpu.matrix-class object with the corresponding distances between the rows of the input gpu.matrix object.
See Also
For more information see:
dist, and torch_cdist.
Examples
## Not run:
#the example compare the results with the
#'stats' function 'dist':
x <- matrix(rnorm(100), nrow = 5)
dist(x,diag = TRUE,upper = TRUE,method = "euclidean")
dist(x = as.gpu.matrix(x),method = "euclidean")
dist(x,diag = TRUE,upper = TRUE,method = "maximum")
dist(x = as.gpu.matrix(x),method = "maximum")
dist(x,diag = TRUE,upper = TRUE,method = "manhattan")
dist(x = as.gpu.matrix(x),method = "manhattan")
dist(x,diag = TRUE,upper = TRUE,method = "minkowski")
dist(x = as.gpu.matrix(x),method = "minkowski")
dist(x,diag = TRUE,upper = TRUE,method = "minkowski",p = 23)
dist(x = as.gpu.matrix(x),method = "minkowski",p = 23)
## End(Not run)