Mercurial > hg > libxtract
diff src/scalar.c @ 229:a2f66a305e53
tristimulus3 correction
author | Sean Enderby <sean.enderby@gmail.com> |
---|---|
date | Tue, 25 Feb 2014 14:12:29 +0000 |
parents | cccd314664ac |
children | b786a835df59 |
line wrap: on
line diff
--- a/src/scalar.c Tue Feb 25 13:53:39 2014 +0000 +++ b/src/scalar.c Tue Feb 25 14:12:29 2014 +0000 @@ -486,21 +486,21 @@ int xtract_tristimulus_3(const double *data, const int N, const void *argv, double *result) { + int n = N >> 1, h = 0, i; + double den = 0.0, num = 0.0, fund = 0.0, temp = 0.0; + const double *freqs; - int n = N, count = 0; + fund = *(double *)argv; + freqs = data + n; - double den, num, temp; - - den = num = temp = 0.0; - - for(n = 0; n < N; n++) + for(i = 0; i < n; i++) { - if((temp = data[n])) + if((temp = data[i])) { den += temp; - if(count >= 5) + h = round(freqs[i] / fund); + if(h >= 5) num += temp; - count++; } }