Update mixing function to avoid fixed point 0

This modification ensures that the mixing function no longer allows the canonical value 0 to always win window comparisons.
Eric Coissac committed 2026-09-12 11:12:45 +02:00
1 parent 2af47f4c1f
commit 98af17f50a
1 file changed
+1 -9
+1 -9
@@ -20,15 +20,7 @@ The hash function is a 64-bit mixing function (splitmix64-style finalizer) appli
$$H(x) = \text{mix64}(x \oplus s), \quad s = \lfloor 2^{64}/\varphi \rfloor = \texttt{0x9e3779b97f4a7c15}$$
```
H(x):
x ← x ⊕ 0x9e3779b97f4a7c15
x ← x ⊕ (x >> 30)
x ← x × 0xbf58476d1ce4e5b9
x ← x ⊕ (x >> 27)
x ← x × 0x94d049bb133111eb
return x ⊕ (x >> 31)
```
$$\begin{aligned} x &\gets x \oplus \texttt{0x9e3779b97f4a7c15} \\ x &\gets x \oplus (x \gg 30) \\ x &\gets x \times \texttt{0xbf58476d1ce4e5b9} \\ x &\gets x \oplus (x \gg 27) \\ x &\gets x \times \texttt{0x94d049bb133111eb} \\ x &\gets x \oplus (x \gg 31) \end{aligned}$$
The XOR seed avoids the finalizer's fixed point at 0 ($\text{mix64}(0) = 0$), which would otherwise make an all-A m-mer (canonical value 0) win every window comparison.