|
@ -615,31 +615,46 @@ namespace storm { |
|
|
typename std::vector<T>::const_iterator sourceIt = source.begin() + *rowGroupingIt; |
|
|
typename std::vector<T>::const_iterator sourceIt = source.begin() + *rowGroupingIt; |
|
|
typename std::vector<T>::const_iterator sourceIte; |
|
|
typename std::vector<T>::const_iterator sourceIte; |
|
|
typename std::vector<uint_fast64_t>::iterator choiceIt; |
|
|
typename std::vector<uint_fast64_t>::iterator choiceIt; |
|
|
uint_fast64_t localChoice; |
|
|
|
|
|
if (choices != nullptr) { |
|
|
|
|
|
|
|
|
if (choices) { |
|
|
choiceIt = choices->begin() + startRow; |
|
|
choiceIt = choices->begin() + startRow; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Variables for correctly tracking choices (only update if new choice is strictly better). |
|
|
|
|
|
T oldSelectedChoiceValue; |
|
|
|
|
|
uint64_t selectedChoice; |
|
|
|
|
|
|
|
|
|
|
|
uint64_t currentRow = 0; |
|
|
for (; targetIt != targetIte; ++targetIt, ++rowGroupingIt, ++choiceIt) { |
|
|
for (; targetIt != targetIte; ++targetIt, ++rowGroupingIt, ++choiceIt) { |
|
|
// Only traverse elements if the row group is non-empty. |
|
|
// Only traverse elements if the row group is non-empty. |
|
|
if (*rowGroupingIt != *(rowGroupingIt + 1)) { |
|
|
if (*rowGroupingIt != *(rowGroupingIt + 1)) { |
|
|
*targetIt = *sourceIt; |
|
|
*targetIt = *sourceIt; |
|
|
++sourceIt; |
|
|
|
|
|
localChoice = 1; |
|
|
|
|
|
if (choices != nullptr) { |
|
|
|
|
|
*choiceIt = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (choices) { |
|
|
|
|
|
selectedChoice = 0; |
|
|
|
|
|
if (*choiceIt == 0) { |
|
|
|
|
|
oldSelectedChoiceValue = *targetIt; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for (sourceIte = source.begin() + *(rowGroupingIt + 1); sourceIt != sourceIte; ++sourceIt, ++localChoice) { |
|
|
|
|
|
|
|
|
++sourceIt; |
|
|
|
|
|
++currentRow; |
|
|
|
|
|
|
|
|
|
|
|
for (sourceIte = source.begin() + *(rowGroupingIt + 1); sourceIt != sourceIte; ++sourceIt, ++currentRow) { |
|
|
|
|
|
if (choices && *choiceIt + *rowGroupingIt == currentRow) { |
|
|
|
|
|
oldSelectedChoiceValue = *sourceIt; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (f(*sourceIt, *targetIt)) { |
|
|
if (f(*sourceIt, *targetIt)) { |
|
|
*targetIt = *sourceIt; |
|
|
*targetIt = *sourceIt; |
|
|
if (choices != nullptr) { |
|
|
|
|
|
*choiceIt = localChoice; |
|
|
|
|
|
|
|
|
if (choices) { |
|
|
|
|
|
selectedChoice = std::distance(source.begin(), sourceIt) - *rowGroupingIt; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} else { |
|
|
|
|
|
*targetIt = storm::utility::zero<T>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (choices && f(*targetIt, oldSelectedChoiceValue)) { |
|
|
|
|
|
*choiceIt = selectedChoice; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -680,6 +695,7 @@ namespace storm { |
|
|
T oldSelectedChoiceValue; |
|
|
T oldSelectedChoiceValue; |
|
|
uint64_t selectedChoice; |
|
|
uint64_t selectedChoice; |
|
|
|
|
|
|
|
|
|
|
|
uint64_t currentRow = 0; |
|
|
for (; targetIt != targetIte; ++targetIt, ++rowGroupingIt, ++choiceIt) { |
|
|
for (; targetIt != targetIte; ++targetIt, ++rowGroupingIt, ++choiceIt) { |
|
|
// Only traverse elements if the row group is non-empty. |
|
|
// Only traverse elements if the row group is non-empty. |
|
|
if (*rowGroupingIt != *(rowGroupingIt + 1)) { |
|
|
if (*rowGroupingIt != *(rowGroupingIt + 1)) { |
|
@ -693,8 +709,10 @@ namespace storm { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
++sourceIt; |
|
|
++sourceIt; |
|
|
for (sourceIte = source.begin() + *(rowGroupingIt + 1); sourceIt != sourceIte; ++sourceIt) { |
|
|
|
|
|
if (choices && selectedChoice == std::distance(source.begin(), sourceIt) - *rowGroupingIt) { |
|
|
|
|
|
|
|
|
++currentRow; |
|
|
|
|
|
|
|
|
|
|
|
for (sourceIte = source.begin() + *(rowGroupingIt + 1); sourceIt != sourceIte; ++sourceIt, ++currentRow) { |
|
|
|
|
|
if (choices && *rowGroupingIt + *choiceIt == currentRow) { |
|
|
oldSelectedChoiceValue = *sourceIt; |
|
|
oldSelectedChoiceValue = *sourceIt; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -710,6 +728,7 @@ namespace storm { |
|
|
*choiceIt = selectedChoice; |
|
|
*choiceIt = selectedChoice; |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
*choiceIt = 0; |
|
|
*targetIt = storm::utility::zero<T>(); |
|
|
*targetIt = storm::utility::zero<T>(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|