FastHamming: Fast Computation of Pairwise Hamming Distances
Ravi Varadhan · 2025
Pairwise Hamming distances are computed between the rows of a binary (0/1) matrix using highly optimized C code. The input is an integer matrix where each row represents a binary feature vector and returns a symmetric integer matrix of pairwise distances. Internally, rows are bit-packed into 64-bit words for fast XOR-based comparisons, with hardware-accelerated popcount operations to count differences. OpenMP parallelization ensures efficient performance for large matrices.