hamming_distance {FastHamming}R Documentation

Pairwise Hamming distances

Description

Computes the pairwise Hamming distances between rows of a binary matrix.

Usage

hamming_distance(X, nthreads = NULL)

Arguments

X

A binary (0/1) numeric matrix.

nthreads

Integer; number of OpenMP threads to use. If NULL (the default) use all available cores,

Value

An integer matrix of pairwise Hamming distances.

Examples


n <- 10000
m <- 1000
set.seed(2468)
X <- matrix(sample(0:1, n * m, replace = TRUE), nrow = n)
# Use all available threads
system.time(result <- hamming_distance(X))
# limit to 2 threads
system.time(hamming_distance(X, nthreads = 2))


[Package FastHamming version 1.2 Index]