@@ -319,7 +319,7 @@ SZ_INTERNAL sz_status_t _sz_levenshtein_distance_skewed_diagonals_serial( //
319319 previous_distances [0 ] = 0 ;
320320 current_distances [0 ] = current_distances [1 ] = 1 ;
321321
322- // Progress through the upper triangle of the Levenshtein matrix.
322+ // Progress through the upper-left triangle of the Levenshtein matrix.
323323 sz_size_t next_diagonal_index = 2 ;
324324 for (; next_diagonal_index != n ; ++ next_diagonal_index ) {
325325 sz_size_t const next_diagonal_length = next_diagonal_index + 1 ;
@@ -338,7 +338,7 @@ SZ_INTERNAL sz_status_t _sz_levenshtein_distance_skewed_diagonals_serial( //
338338 next_distances = temporary ;
339339 }
340340
341- // By now we've scanned through the upper triangle of the matrix, where each subsequent iteration results in a
341+ // By now we've scanned through the upper-left triangle of the matrix, where each subsequent iteration results in a
342342 // larger diagonal. From now onwards, we will be shrinking. Instead of adding value equal to the skewed diagonal
343343 // index on either side, we will be cropping those values out.
344344 sz_size_t diagonals_count = n + n - 1 ;
@@ -836,7 +836,7 @@ SZ_INTERNAL sz_size_t _sz_levenshtein_distance_skewed_diagonals_upto63_ice( //
836836 sz_size_t next_diagonal_index = 2 ;
837837 __mmask64 next_diagonal_mask = 0 ;
838838
839- // Progress through the upper triangle of the Levenshtein matrix.
839+ // Progress through the upper-left triangle of the Levenshtein matrix.
840840 for (; next_diagonal_index != shorter_dim ; ++ next_diagonal_index ) {
841841 // After this iteration, the values at offset `0` and `next_diagonal_index` in the `next_vec`
842842 // should be set to `next_diagonal_index`, but it's easier to broadcast the value to the whole vector,
@@ -869,7 +869,7 @@ SZ_INTERNAL sz_size_t _sz_levenshtein_distance_skewed_diagonals_upto63_ice( //
869869 if (_ktestz_mask64_u8 (within_bound_mask , next_diagonal_mask ) == 1 ) return bound ;
870870 }
871871
872- // Now let's handle the anti-diagonal band of the matrix, between the top and bottom triangles.
872+ // Now let's handle the anti-diagonal band of the matrix, between the top and bottom-right triangles.
873873 for (; next_diagonal_index != longer_dim ; ++ next_diagonal_index ) {
874874 // After this iteration, the value `shorted_dim - 1` in the `next_vec`
875875 // should be set to `next_diagonal_index`, but it's easier to broadcast the value to the whole vector,
@@ -1072,7 +1072,7 @@ SZ_INTERNAL sz_status_t _sz_levenshtein_distance_skewed_diagonals_upto65k_ice( /
10721072 // - 3 diagonals of decreasing length, at positions: 6, 7, 8.
10731073 sz_size_t const diagonals_count = shorter_dim + longer_dim - 1 ;
10741074
1075- // Progress through the upper triangle of the Levenshtein matrix.
1075+ // Progress through the upper-left triangle of the Levenshtein matrix.
10761076 sz_size_t next_diagonal_index = 2 ;
10771077 for (; next_diagonal_index != shorter_dim ; ++ next_diagonal_index ) {
10781078 sz_size_t const next_diagonal_length = next_diagonal_index + 1 ;
@@ -1118,7 +1118,7 @@ SZ_INTERNAL sz_status_t _sz_levenshtein_distance_skewed_diagonals_upto65k_ice( /
11181118 next_distances = temporary ;
11191119 }
11201120
1121- // By now we've scanned through the upper triangle of the matrix, where each subsequent iteration results in a
1121+ // By now we've scanned through the upper-left triangle of the matrix, where each subsequent iteration results in a
11221122 // larger diagonal. From now onwards, we will be shrinking. Instead of adding value equal to the skewed diagonal
11231123 // index on either side, we will be cropping those values out.
11241124 for (; next_diagonal_index != diagonals_count ; ++ next_diagonal_index ) {
@@ -1216,7 +1216,9 @@ SZ_PUBLIC sz_status_t sz_levenshtein_distance_ice( //
12161216}
12171217
12181218/**
1219- * Computes the Needleman Wunsch alignment score between two strings.
1219+ * @brief Computes the Needleman-Wunsch alignment score between two strings. Uses the Wagner-Fischer algorithm
1220+ * with the AVX-512VBMI extensions, vectorizing the substitution costs in each row.
1221+ *
12201222 * The method uses 32-bit integers to accumulate the running score for every cell in the matrix.
12211223 * Assuming the costs of substitutions can be arbitrary signed 8-bit integers, the method is expected to be used
12221224 * on strings not exceeding 2^24 length or 16.7 million characters.
0 commit comments