Learn R Programming

largeVis (version 0.2.1.1)

distance: Calculate pairwise Euclidean or angular distances efficiently

Description

This function is a wrapper around a C++ function that calculates pairwise distances in a memory- and CPU-efficient manner.

Usage

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))

Arguments

x

A (potentially sparse) matrix, where examples are columns and features are rows.

i

0-indexed vector of column indices.

j

0-indexed vector of column indices.

distance_method

One of "Euclidean" or "Cosine."

threads

The maximum number of threads to spawn. Determined automatically if NULL (the default).

verbose

Verbosity.

Value

A vector of the distances between the columns in `x` indexed by `i` and `j`, with attribute method giving the distance_method.

Details

The Euclidean or angular distances between columns in `x` identified by parameters `i` and `j` are calculated and returned.