src/features/reduce.c file

Functions

static auto neumaier_step(const vm_float_t sum, vm_float_t* comp, const vm_float_t x) -> vm_float_t
One Neumaier step.
auto vm_sum_compensated(const vm_float_t* x, int n) -> vm_float_t
Neumaier sum of x[0..n).
auto vm_dot_compensated(const vm_float_t* a, const vm_float_t* b, int n) -> vm_float_t
Neumaier dot product of a and b.
auto vm_array_minmax(vm_float_t* min_value, vm_float_t* max_value, const vm_float_t* x, int n) -> bool
Minimum and maximum, ignoring NaNs.

Function documentation

static vm_float_t neumaier_step(const vm_float_t sum, vm_float_t* comp, const vm_float_t x)

One Neumaier step.

t is stored so the lost low part survives optimization.

vm_float_t vm_sum_compensated(const vm_float_t* x, int n)

Neumaier sum of x[0..n).

Returns Compensated sum, or +0 when n <= 0.

n <= 0 returns +0 and does not read. On finite non-overflow inputs with n <= 10^6, the absolute error is at most 16 eps × sum(|terms|). The same binary and input repeat.

vm_float_t vm_dot_compensated(const vm_float_t* a, const vm_float_t* b, int n)

Neumaier dot product of a and b.

Parameters
a Left input; length n. Ignored when n <= 0.
b Right input; length n. May exactly alias a.
n
Returns Compensated dot, or +0 when n <= 0.

The product is formed in vm_float_t, then compensated. a may exactly alias b. n <= 0 returns +0 and does not read. The absolute-error target matches vm_sum_compensated.

bool vm_array_minmax(vm_float_t* min_value, vm_float_t* max_value, const vm_float_t* x, int n)

Minimum and maximum, ignoring NaNs.

Parameters
min_value Output minimum. Unchanged on failure.
max_value Output maximum. Unchanged on failure.
x
n
Returns true when at least one non-NaN value was seen.

n <= 0, a missing pointer, or an all-NaN input returns false and leaves *min_value and *max_value unchanged. Infinities count. The minimum of ±0 is −0 and the maximum is +0. A selected finite or infinite value is exact.