diff --git a/Framework/Kernel/src/VectorHelper.cpp b/Framework/Kernel/src/VectorHelper.cpp index 02ed7bcd6f0f7f54b1aea402b9bf5fb09fe978d5..7c56ee11a74cf01aefd49cbe3b3f885aa4ad610f 100644 --- a/Framework/Kernel/src/VectorHelper.cpp +++ b/Framework/Kernel/src/VectorHelper.cpp @@ -582,6 +582,11 @@ double runAverage(size_t index, size_t startIndex, size_t endIndex, weight1 = (end - binBndrs->operator[](iEnd)) / (binBndrs->operator[](iEnd + 1) - binBndrs->operator[](iEnd)); } + if (iStart > iEnd) { // start and end get into the same bin + weight1 = 0; + weight0 = (end - start) / + (binBndrs->operator[](iStart)-binBndrs->operator[](iStart - 1)); + } } else { // integer indexes and functions defined in the bin centers iStart = index - static_cast<size_t>(halfWidth); if (startIndex + static_cast<size_t>(halfWidth) > index) @@ -590,11 +595,6 @@ double runAverage(size_t index, size_t startIndex, size_t endIndex, if (iEnd > endIndex) iEnd = endIndex; } - if (iStart > iEnd) { // start and end get into the same bin - weight1 = 0; - weight0 = (end - start) / - (binBndrs->operator[](iStart)-binBndrs->operator[](iStart - 1)); - } double avrg = 0; size_t ic = 0; @@ -612,7 +612,7 @@ double runAverage(size_t index, size_t startIndex, size_t endIndex, } else { return avrg / double(ic); } -}; +} } /** Basic running average of input vector within specified range, considering * variable bin-boundaries if such boundaries are provided.