sparse_pairwise computes similarity between pairs of rows of a matrix.

sparse_pairwise(X, id1, id2, pairwise_function, use_furrr = FALSE)

Arguments

X

matrix

id1

vector of integers specifying the list of rows of X (first set)

id2

vector of integers specifying the list of rows of X, (second set), same length as id1.

pairwise_function

function that takes a matrix and a pair of indices specifying rows of the matrix, and computes an operation of each pair of rows

use_furrr

boolean indicating whether to use the furrr library for parallel processing.

Value

data.frame with the same number of rows as the length of id1

(and id2) containing the similarity between the pairs of rows of X. sim[i] == pairwise_function(X[id1[i], ], X[id2[i], ]).