Computes the Kahan compensated sum over a range.

Synopsis

Declared in <folly/math/KahanSummation.h>

template<std::ranges::input_range R>
requires std::floating_point<std::ranges::range_value_t<R>>
std::ranges::range_value_t<R>
kahan_sum(R&& range);

Return Value

The compensated sum of all elements in the range.

Template Parameters

Name

Description

R

An input range whose value type is a floating‐point type.

Parameters

Name

Description

range

The range to sum.

Created with MrDocs