This function is a wrapper around a C++ function that calculates pairwise distances in a memory- and CPU-efficient manner.
distance(x, i, j, distance_method, threads = NULL, verbose)# S3 method for matrix
distance(x, i, j, distance_method = "Euclidean",
threads = NULL, verbose = getOption("verbose", TRUE))
# S3 method for CsparseMatrix
distance(x, i, j, distance_method = "Euclidean",
threads = NULL, verbose = getOption("verbose", TRUE))
# S3 method for TsparseMatrix
distance(x, i, j, distance_method = "Euclidean",
threads = NULL, verbose = getOption("verbose", TRUE))
A (potentially sparse) matrix, where examples are columns and features are rows.
0-indexed vector of column indices.
0-indexed vector of column indices.
One of "Euclidean" or "Cosine."
The maximum number of threads to spawn. Determined automatically if NULL
(the default).
Verbosity.
A vector of the distances between the columns in `x` indexed by `i` and `j`, with attribute method
giving the distance_method
.
The Euclidean or angular distances between columns in `x` identified by parameters `i` and `j` are calculated and returned.