Skip to content
Snippets Groups Projects
Commit cab6c162 authored by Martyn Gigg's avatar Martyn Gigg
Browse files

Improve readability of loop stop condition

parent cf159677
No related merge requests found
...@@ -1473,9 +1473,7 @@ double IndexingUtils::GetFirstMaxIndex(const double magnitude_fft[], size_t N, ...@@ -1473,9 +1473,7 @@ double IndexingUtils::GetFirstMaxIndex(const double magnitude_fft[], size_t N,
if (found_max) { if (found_max) {
double sum = 0; double sum = 0;
double w_sum = 0; double w_sum = 0;
// only include single extra index if we're too near the end for (size_t j = i - 2; j < std::min(N, i + 3); j++) {
const size_t last_index = i < N - 2 ? i + 2 : i + 1;
for (size_t j = i - 2; j <= last_index; j++) {
sum += static_cast<double>(j) * magnitude_fft[j]; sum += static_cast<double>(j) * magnitude_fft[j];
w_sum += magnitude_fft[j]; w_sum += magnitude_fft[j];
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment