Files
pplus-library/modules/numerics/kahan-sum/ref/c/plain.c
T
alexm 568474d52f
Test (in pplus-core) / in-core (push) Failing after 28m44s
Initial commit
2026-11-12 22:23:48 -05:00

11 lines
245 B
C

double kahan_sum(const double *x, long n) {
double total = 0.0, c = 0.0;
for (long i = 0; i < n; i++) {
double y = x[i] - c;
double t = total + y;
c = (t - total) - y;
total = t;
}
return total;
}