[−][src]Function triple_accel::levenshtein::levenshtein_simd_k
pub fn levenshtein_simd_k(a: &[u8], b: &[u8], k: u32) -> Option<u32>
Returns the Levenshtein distance, bounded by a cost threshold k
, between two strings, using
SIMD acceleration.
This will return None
if the Levenshtein distance between a
and b
is greater than the
threshold k
.
This should be much faster than levenshtein_naive
and levenshtein_naive_k
.
Internally, this will automatically use AVX or SSE vectors with 8-bit, 16-bit, or 32-bit elements
to represent anti-diagonals in the dynamic programming matrix for calculating Levenshtein distance.
If AVX2 or SSE4.1 is not supported, then this will automatically fall back to
levenshtein_naive_k_with_opts
.
Arguments
a
- first string (slice)b
- second string (slice)k
- maximum number of edits allowed betweena
andb
Example
let dist = levenshtein_simd_k(b"abc", b"ab", 1); assert!(dist.unwrap() == 1);