Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save calvin2021y/6f085a37c70114682330d756a6fa793f to your computer and use it in GitHub Desktop.
Save calvin2021y/6f085a37c70114682330d756a6fa793f to your computer and use it in GitHub Desktop.
LCG/MCG multiplier tables for 32 & 64 bits
// 1) "Tables of linear congruential generators of different sizes and good lattice structure" (1999), Pierre L'Ecuyer
// 2) Pre-print version of (3) (https://arxiv.org/abs/2001.05304)
// 3) "Computationally easy, spectrally good multipliers for congruential pseudorandom number generators" (2021), Guy L. Steele Jr. & Sebastiano Vigna (https://onlinelibrary.wiley.com/doi/epdf/10.1002/spe.3030)
// inline comment number is bit width of constant
const uint32_t lcg_mul_k_table_32[] =
{
// (3) Table 4 LCGs
0x0000d9f5, // 16
0x0001dab5, // 17
0x0003d575, // 18
0x00c083c5, // 24
0x915f77f5, // 32
// (3) Table 5 MCGs
0x000072ed, // 15
0x0000ecc5, // 16
0x0001e92d, // 17
0x00039e2d, // 18
0x00e47135, // 24
0x93d765dd, // 32
// (2) Table 3 LCGs
0x0000fb85, // 16
0x0000d09d,
0x0001d6cd, // 17
0x00019c05,
0x0003956d, // 18
0x000342dd,
0x0006ebd5, // 19
0x0007c8a5,
0x0006d7f5,
0x0007e57d,
0x00e027a5, // 24
//0x00c083c5, repeat
0x00ca7b35,
0x00e8fd45,
0xadb4a92d, // 32
0xa13fc965,
0x8664f205,
0xcf019d85,
// (2) Table 4 MCGs
0x00007dc5, // 15
0x0000756d,
//0x000072ed, repeat
0x0000f7b5, // 16
0x0000c075,
0x0001d205, // 17
0x0001c77d,
0x000305d5, // 18
0x0003c965,
0x00031e2d,
//0x000305d5, repeat
0x0007ecc5, // 19
0x000728cd,
0x0006be35,
0x00076e3d,
0x00c00e35, // 24
0x00c7fb6d,
0xae3cc725, // 32
0x9fe72885,
0xae36bfb5,
0x82c1fcad,
// (1) Table 4 LCGs
0xac564b05,
0x01c8e815,
0x01ed0675,
// (1) Table 5 MCGs
0x2c2c57ed,
0x5f356495,
0x2c9277b5
};
const uint64_t lcg_mul_k_table_64[] =
{
// (3) Table 6 LCGs
0x00000000f9b25d65, // 32
0x000000018a44074d, // 33
0x00000003af78c385, // 34
0x0000c2ec33ef97a5, // 48
0xd1342543de82ef95, // 64
// (3) Table 7 MCGs
0x00000000e817fb2d, // 32
0x00000001e85bbd25, // 33
0x000000034edd34ad, // 34
0x0000bdcdbb079f8d, // 48
0xf1357aea2e62a9c5, // 64
// (2) Table 5 LCGs
0x00000000ff2826ad, // 32
0x00000000f691b575,
0x00000000f2fc5985,
0x00000000ff1cd035,
0x00000001dce91c05, // 33
0x000000019a28f105,
0x00000001e5a5a195,
0x00000001e179ae9d,
0x00000003dd03af2d, // 34
//0x00000003af78c385, repeat
0x00000003631069bd,
0x000000030761063d,
0x00000006bf6b1a55, // 35
0x0000000758d4ae8d,
0x000000069803d095,
0x000087338161ef95, // 48
0x0000b67a49a5466d,
0x00008616afca102d,
0x0000bc1afb38ad6d,
//0xd1342543de82ef95, // 64 repeat
0xaf251af3b0f025b5,
0xb564ef22ec7aece5,
0xf7c2ebc08f67f2b5,
// (2) Table 6 MCGs
0x00000000e9c5aaa5, // 32
0x00000000f8e86b9d,
0x00000000d3733915,
0x00000000ecbce6ad,
0x00000001efc38315, // 33
0x00000001feec73b5,
0x00000001d5e995ed,
0x00000001ec77d545,
0x000000032a4e0b8d, // 34
0x00000003dd6e1fa5,
0x000000036b370ff5,
0x000000037900045d,
0x000000076826be35, // 35
0x000000077a0b8d0d,
//0x000000076826be35, repeat
0x0000e1aadae62835, // 48
0x0000f6473f07ba5d,
0x0000c3be54e6b3dd,
//0x0000bdcdbb079f8d, repeat
0xcc62fceb9202faad, // 64
0xcb9c59b3f9f87d4d,
0xfa346cbfd5890825,
0x83b5b142866da9d5,
// (1) Table 4 LCGs
0x27bb2ee687b0b0fd,
0x2c6fe96ee78b6955,
0x369dea0f31a53f85,
// (1) Table 5 MCGs
0x106689d45497fdb5,
0x6a5d39eae116586d,
0x2545f4914f6cdd1d
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment