Skip to content

Commit

Permalink
switching to parallel iterators where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
nrminor committed Feb 4, 2024
1 parent 7bc8a40 commit 2f154d4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/lib/distmat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ fn adjusted_hamming(alpha: &[u8], beta: &[u8]) -> f64 {
let beta_n_count = beta.par_iter().filter(|&&base| base == b'N').count();

// compute an offset to subtract from the raw distance
let mask_offset = (alpha_n_count + beta_n_count) as f64;
let mask_offset = if alpha_n_count > beta_n_count {
alpha_n_count as f64
} else {
beta_n_count as f64
};

// compute this distance score with a Rust-bio SIMD computation
let unadjusted_dist = hamming(alpha, beta) as f64;
Expand All @@ -116,7 +120,11 @@ fn adjusted_levenshtein(alpha: &[u8], beta: &[u8]) -> f64 {
let beta_n_count = beta.par_iter().filter(|&&base| base == b'N').count();

// compute an offset to subtract from the raw distance
let mask_offset = (alpha_n_count + beta_n_count) as f64;
let mask_offset = if alpha_n_count > beta_n_count {
alpha_n_count as f64
} else {
beta_n_count as f64
};

// compute this distance score with a Rust-bio SIMD computation
let unadjusted_dist = levenshtein(alpha, beta) as f64;
Expand Down

0 comments on commit 2f154d4

Please sign in to comment.