From 41bf3013e2d5f0bd34ab907fba98a89f25e5055c Mon Sep 17 00:00:00 2001 From: Brendan O'Donoghue Date: Mon, 1 Jan 2024 13:20:49 +0000 Subject: [PATCH] tweak accumulation of average --- src/aa.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/aa.c b/src/aa.c index 061b9d1b..acad4960 100644 --- a/src/aa.c +++ b/src/aa.c @@ -138,7 +138,9 @@ aa_float aa_apply(aa_float *f, const aa_float *x, AaWork *a) { for (i = 0; i < a->dim; ++i) { /* accumulate the average */ - a->x[i] = (a->x[i] * a->iter + f[i]) / (a->iter + 1); + a->x[i] *= a->iter / (a->iter + 1); + a->x[i] += f[i] / (a->iter + 1); + /* a->x[i] = (a->x[i] * a->iter + f[i]) / (a->iter + 1); */ } a->iter++;