#ifndef LEVENSHTEIN_H #define LEVENSHTEIN_H #include #include // Source: https://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Levenshtein_distance size_t levenshtein_distance_serial(const void* s1, size_t len1, const void* s2, size_t len2, bool unicode); /// By-rows multi-threaded implementation with Pthreads size_t levenshtein_distance_pthreads_byrows(const void* s1, size_t len1, const void* s2, size_t len2, bool unicode, size_t* workers); /// Diagonal multi-threaded implementation with Pthreads size_t levenshtein_distance_pthreads_diagonal(const void* s1, size_t len1, const void* s2, size_t len2, bool unicode, size_t* workers); /// Uses two matrices to avoid one of the three dependences that each cell has size_t levenshtein_distance_pthreads_guo(const void* s1, size_t len1, const void* s2, size_t len2, bool unicode, size_t* workers); // Common subroutines ============================================================================= #define min(a,b) (((a)<(b))?(a):(b)) #define max(a,b) (((a)>(b))?(a):(b)) #define min3(a,b,c) (min(a, min(b,c))) /// Create a matrix of distances in heap memory size_t** create_distance_matrix(size_t rows, size_t cols); /// Destroy a matrix of distances in heap memory void destroy_distance_matrix(size_t** matrix, size_t rows); #endif // LEVENSHTEIN_H