Skip to content

Commit

Permalink
Fixed issue #85.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martinsos committed Sep 9, 2017
1 parent 5141531 commit c12b5e1
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions edlib/src/edlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,13 +578,24 @@ static int myersCalcEditDistanceSemiGlobal(
}
}

// Every some columns, do some expensive but also more efficient block reducing -> this is important!
// Every some columns, do some expensive but also more efficient block reducing.
// This is important!
//
// Reduce the band by decreasing last block if possible.
if (c % STRONG_REDUCE_NUM == 0) {
while (lastBlock >= firstBlock && allBlockCellsLarger(*bl, k)) {
while (lastBlock >= 0 && lastBlock >= firstBlock && allBlockCellsLarger(*bl, k)) {
lastBlock--; bl--; Peq_c--;
}
}
// For HW, even if all cells are > k, there still may be solution in next
// column because starting conditions at upper boundary are 0.
// That means that first block is always candidate for solution,
// and we can never end calculation before last column.
if (mode == EDLIB_MODE_HW && lastBlock == -1) {
lastBlock++; bl++; Peq_c++;
}

// Reduce band by increasing first block if possible. Not applicable to HW.
if (mode != EDLIB_MODE_HW) {
while (firstBlock <= lastBlock && blocks[firstBlock].score >= k + WORD_SIZE) {
firstBlock++;
Expand All @@ -596,14 +607,6 @@ static int myersCalcEditDistanceSemiGlobal(
}
}

// For HW, even if all cells are > k, there still may be solution in next
// column because starting conditions at upper boundary are 0.
// That means that first block is always candidate for solution,
// and we can never end calculation before last column.
if (mode == EDLIB_MODE_HW) {
lastBlock = max(0, lastBlock);
}

// If band stops to exist finish
if (lastBlock < firstBlock) {
*bestScore_ = bestScore;
Expand Down

0 comments on commit c12b5e1

Please sign in to comment.