37 template <
typename FloatType>
51 jassert (juce_isfinite (v));
57 if (v > maximum) maximum = v;
58 if (v < minimum) minimum = v;
72 return count > 0 ? sum / (FloatType) count
81 return count > 0 ? (sumSquares - sum * sum / (FloatType) count) / (FloatType) count
119 KahanSum() =
default;
120 operator FloatType() const noexcept {
return sum; }
122 void JUCE_NO_ASSOCIATIVE_MATH_OPTIMISATIONS operator+= (FloatType value) noexcept
124 FloatType correctedValue = value - error;
125 FloatType newSum = sum + correctedValue;
126 error = (newSum - sum) - correctedValue;
130 FloatType sum{}, error{};
135 KahanSum sum, sumSquares;
136 FloatType minimum { std::numeric_limits<FloatType>::infinity() },
137 maximum { -std::numeric_limits<FloatType>::infinity() };