Skip to content

Instantly share code, notes, and snippets.

/*
Experiemental versions of improving the stat properties of a 32-bit (for embedded devices) xorshift
without restorting to adding state data. The two versions add one to the dependency chain.
Based directly on the work of Sebastiano Vigna - http://xorshift.di.unimi.it/
*/
uint32_t state = 1;
// no failures from small crush,
// one questionable from small crush (bit reversed)
// 6 MaxOft
// failure from crush
// 72 LinearComp, r = 29
uint32_t xorshift32ma(void)
{
int s0 = state;
Under the cygwin 64 (http://www.cygwin.org/ - setup-x86_64.exe)
Known required packages (from package manager - setup-x86_64.exe):
make (used 4.0.2)
gcc (used 4.9.2)
libxml2-dev (used 2.9.2-1)
These will have a number of dependent packages which the manager will ask if you want to install
as well...and of course it's yes.
@Marc-B-Reynolds
Marc-B-Reynolds / gist:31f997b3ef0398da6c46
Created October 14, 2015 11:46
32-bit single state off-the-shelf basic xorshift - bruteforce all configurations smallcrush results
Run of all single state 32-bit xorshifts through SmallCrush.
All started with seed of '1', not reset between tests in
the battery.
The results of each generator start with a heading like this:
Generator: X1 LRL (25,7,2)
"Xn" is the name of the generator type
LRL is the directions of the shifts

This is total shit quickly banged out in probably hard to follow semi-formalism.

TL/DR part, skip to next section

Complex numbers (C) can be viewed as a scalar bivector pair. A 2D bivector requires 1 element (note 1), so we have C ~= R1+R1 ~= R2 with basis {1,i}.

Denote a complex number: z = a+bi = (a, b), {a,b} on R. Associating C with R2 we can interpret (a,b) as a coordinate (in the plane). Functions over C map coordinates in the plane to other coordinates in the plane. We can define principle value (single valued) functions for: log, exp and powers (among others).

For power we can rewrite 'z' into a polar form z = m(cos(a), sin(a)), m >= 0, a on [pi,-pi). Then the princle power can be denoted as:

zt = mt(cos(ta), sin(ta))

@Marc-B-Reynolds
Marc-B-Reynolds / u32_weyl_2d_hash.txt
Last active February 23, 2016 10:03
An example 2D hash function based on Weyl generators
// 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;
@Marc-B-Reynolds
Marc-B-Reynolds / u24_weyl_2d_hash
Created February 23, 2016 14:22
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:
@Marc-B-Reynolds
Marc-B-Reynolds / prns_1.txt
Last active July 18, 2016 03:51
prns.h std config results
http://github.com/Marc-B-Reynolds/Stand-alone-junk/blob/master/src/SFH/prns.h
PRNS with configuation options (standard)
WEYL: 0x61c8864680b583eb
S0: 31
S1: 27
drops last right-xorshift
M0: 0x7fb5d329728ea185
M1: 0x81dadef4bc2dd44d
high bits
@Marc-B-Reynolds
Marc-B-Reynolds / prns_smallcrush.txt
Created July 18, 2016 09:47
PRNS configured for small crush report
PRNS with configuation options (smallcrush)
high bits
run 1 -- state = 0x2050cfa9a239f
========= Summary results of SmallCrush =========
Version: TestU01 1.2.3
Generator: prns
Number of statistics: 15
Total CPU time: 00:00:05.06
@Marc-B-Reynolds
Marc-B-Reynolds / prideout.md
Last active August 15, 2016 10:04
Toy thought about: Messy closed path within ball in 3D