fix autocorrelation: convert divisor to float64

both for Autocorrelate and AutocorrelateMP, even though for the latter
the change only covers converting the divisor expression as a whole,
instead of individual elements separately.
This commit is contained in:
leo 2023-02-25 13:40:16 +01:00
parent 4bf633dc5b
commit 37f15b9fa6
Signed by: wanderer
SSH Key Fingerprint: SHA256:Dp8+iwKHSlrMEHzE3bJnPng70I7LEsa3IJXRH/U+idQ

@ -29,8 +29,7 @@ func Autocorrelate(f []float64, maxShift float64) []float64 {
r += f[i] * f[i+currentShift]
}
// r = r * math.Pow(float64(fLen)-float64(currentShift), -1)
r *= float64(1 / (fLen - currentShift))
r *= 1 / float64(fLen-currentShift)
v = append(v, r)
@ -53,7 +52,7 @@ func AutocorrelateMP(f []float64, maxShift float64) []float64 {
r += f[i] * f[i+currentShift]
}
r *= math.Pow(float64(fLen)-float64(currentShift), -1)
r *= math.Pow(float64(fLen-currentShift), -1)
v = append(v, r)