diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2017-11-02 11:02:07 -0400 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2017-11-02 11:02:07 -0400 |
commit | 30534606d5690e176d168f640f55162fa15f0a19 (patch) | |
tree | 30a982262f062bd92a467b2b21b2142dbd90df97 /lib/wolff_tools.c | |
parent | a0db32c0ad05fbe2753d44b1e82f608d99bd9742 (diff) | |
download | c++-30534606d5690e176d168f640f55162fa15f0a19.tar.gz c++-30534606d5690e176d168f640f55162fa15f0a19.tar.bz2 c++-30534606d5690e176d168f640f55162fa15f0a19.zip |
major changes (again) to the measurement of autocorrelation
Diffstat (limited to 'lib/wolff_tools.c')
-rw-r--r-- | lib/wolff_tools.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/lib/wolff_tools.c b/lib/wolff_tools.c index 92e8302..a417d4e 100644 --- a/lib/wolff_tools.c +++ b/lib/wolff_tools.c @@ -258,21 +258,31 @@ void update_autocorr(autocorr_t *OO, double O) { OO->O = add_to_avg(OO->O, O, OO->n); OO->O2 = add_to_avg(OO->O2, pow(O, 2), OO->n); - uint64_t lim = OO->W; - - if (OO->n < OO->W) { - lim = OO->n; + dll_t *Otmp = OO->Op; + dll_t *Osave; + uint64_t t = 0; + + while (Otmp != NULL) { + OO->OO[t] = add_to_avg(OO->OO[t], O * (Otmp->x), OO->n - t - 1); + t++; + if (t == OO->W - 1) { + Osave = Otmp; + } + Otmp = Otmp->next; } - for (uint64_t t = 0; t < lim; t++) { - OO->OO[t] = add_to_avg(OO->OO[t], O * OO->Op[t], OO->n - t - 1); + if (t == OO->W) { + if (OO->W == 1) { + free(OO->Op); + OO->Op = NULL; + } else { + free(Osave->next); + Osave->next = NULL; + } } - for (uint64_t t = 0; t < OO->W - 1; t++) { - OO->Op[OO->W - 1 - t] = OO->Op[OO->W - 2 - t]; - } + stack_push_d(&(OO->Op), O); - OO->Op[0] = O; OO->n++; } |