Skip to content

Instantly share code, notes, and snippets.

@Marc-B-Reynolds
Created February 23, 2016 14:22
Show Gist options
  • Save Marc-B-Reynolds/60ff744ad07ca791b02a to your computer and use it in GitHub Desktop.
Save Marc-B-Reynolds/60ff744ad07ca791b02a to your computer and use it in GitHub Desktop.
24 bit 2D Weyl hash
// first attempt - poor search for the final const
x = (9303801 * x) & 0xFFFFFF;
y = (5176057 * y) & 0xFFFFFF;
x ^= y;
x = (5056925 * x) & 0xFFFFFF;
return x;
-------------
Mathematica:
pow = 9;
size = 2^pow;
c0 = -size/2;
c1 = -c0 - 1;
f[a_, b_] := Module[
{ x = a,
y = b},
x = BitAnd[x*9303801, 2^24 - 1];
y = BitAnd[y*5176057, 2^24 - 1];
x = BitXor[x, y];
BitAnd[x*5056925, 2^24 - 1]
];
image = Image[Table[f[x, y]*2^-24, {y, c0, c1}, {x, c0, c1}]];
spectra = ImagePeriodogram[image];
GraphicsRow[{image, spectra}, ImageSize -> Full]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment