Last active
February 23, 2016 10:03
-
-
Save Marc-B-Reynolds/5a939f71fc7237c7af63 to your computer and use it in GitHub Desktop.
An example 2D hash function based on Weyl generators
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 32-bit example...same holds for 64-bit | |
uint32_t hash(uint32_t x, uint32_t y) | |
{ | |
// line = dependency | |
x *= 0x3504f333; y *= 0xf1bbcdcb; // 1: scaled & rounded to odd (just from mollwollfumble's example) | |
x ^= y; // 2: cheap combine on the two dimensions (2-adic op on purpose) | |
x *= 741103597; // 3: MLCG constant of good merit | |
return x; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment