Function hamming_rs::distance

source ·
pub fn distance(x: &[u8], y: &[u8]) -> u64
Expand description

Computes hamming distance
Assumes x and y have same memory alignment
Uses highly optimized avx2 version if available
fallback on distance_faster if x and y have different alignment or if avx2 features are not available

Arguments

  • x - a byte slice (prefer 32 byte alignment to get highest performance)
  • y - same

Examples

use hamming_rs::distance;
let x: [u8;5] = [0, 1, 2, 3, 4];
let y: [u8;5] = [0, 1, 3, 2, 4];
let dist = distance(&x, &y);
assert_eq!(2, dist);