Cayley
Pseudo-Random Bits from Finite Groups
Cayley32.cpp
Go to the documentation of this file.
1 
4 #include "Includes.h"
5 #include "Cayley32.h"
6 
8 //Cayley32e functions
9 
11 } //constructor
12 
19 
20 uint64_t Cayley32e::rand(){
21  NextPerm(); //update current permutation
22  CPerm& perm = *m_pCurPerm; //shorthand for the current permutation
23 
24  uint64_t num =
25  (perm[ 0]*0x0d7e11b44d8e8161) ^ (perm[ 1]*0x3d43a82e494a9972) ^
26  (perm[ 2]*0x71b941e4c1557ec7) ^ (perm[ 3]*0x56bf34559248d37c) ^
27  (perm[ 4]*0x445db48764d3c5c8) ^ (perm[ 5]*0xd2b96a4ba16b5c56) ^
28  (perm[ 6]*0xb2bbaa127223e3da) ^ (perm[ 7]*0x3232fd669cd2918e) ^
29  (perm[ 8]*0x331d3d1bd619e971) ^ (perm[ 9]*0x74b3680644295539) ^
30  (perm[10]*0xb491addfb1af0f5b) ^ (perm[11]*0xa3caa6455b313d54) ^
31  (perm[12]*0xb6257e45a726fa52) ^ (perm[13]*0xd413cd54747f43b1) ^
32  (perm[14]*0x706873eeb3583e05) ^ (perm[15]*0x3fd0d37b7f24589c) ^
33  (perm[16]*0xc04cb886d76abce0) ^ (perm[17]*0x3ecfdec3d519aedd) ^
34  (perm[18]*0xbb4f1bccb25c3e51) ^ (perm[19]*0xb1b80c550732d50f) ^
35  (perm[20]*0x7c5015c795b5c8c2) ^ (perm[21]*0xb2d8190706c770a8) ^
36  (perm[22]*0x0d7e11b44d8e8161) ^ (perm[23]*0x3d43a82e494a9972) ^
37  (perm[24]*0x71b941e4c1557ec7) ^ (perm[25]*0x56bf34559248d37c) ^
38  (perm[26]*0x445db48764d3c5c8) ^ (perm[27]*0xd2b96a4ba16b5c56) ^
39  (perm[28]*0xb2bbaa127223e3da) ^ (perm[29]*0x3232fd669cd2918e) ^
40  (perm[30]*0x331d3d1bd619e971) ^ (perm[31]*0x74b3680644295539);
41 
42  m_nDelayLine[m_nTail] = num; //enter into delay line
43  m_nTail = (m_nTail + 1)%m_nDelay; //advance delay line
44 
45  return num^m_nDelayLine[m_nTail]; //strengthen pseudo-random number
46 } //rand
47 
49 //Cayley32 functions
50 
53 
55 } //constructor
56 
62 
64  uintx_t gen0("350F1C2036E12600512A8400920E");
65  uintx_t gen1("EEDC82EE2D472B430D13E5066CD5B");
66 
67  m_nPower[0].Initialize(CPerm(32, gen0));
68  m_nPower[1].Initialize(CPerm(32, gen1));
69 
70  assert(m_nPower[0].GetOrder() == m_nOrder);
71  assert(m_nPower[1].GetOrder() == m_nOrder);
72 } //ChooseGenerators
73 
77 
80  *m_pCurPerm = CPerm(32, seed); //pseudorandom initial permutation
81 } //srand
Cayley32e()
Constructor.
Definition: Cayley32.cpp:10
Useful includes.
CPerm * m_pCurPerm
Current permutation.
Definition: Cayley.h:30
uint32_t m_nOrder
Order of generators.
Definition: Cayley.h:28
void ChooseGenerators()
Choose generators.
Definition: Cayley32.cpp:63
void NextPerm()
Compute next permutation.
Definition: Cayley.cpp:128
void srand(uintx_t &seed)
Seed the generator.
Definition: Cayley32.cpp:78
Declaration of the Cayley32 pseudo-random number generator.
Permutation.
Definition: Permutation.h:20
int m_nTail
Index of last element in delay line.
Definition: Cayley.h:53
The extensible unsigned integer class.
Definition: uintx_t.h:14
CPowerTable m_nPower[2]
Power tables for a pair of generators.
Definition: Cayley.h:29
void Initialize(const CPerm &p)
Initialize.
Definition: PowerTable.cpp:17
Cayley32()
Constructor.
Definition: Cayley32.cpp:54
static const int m_nDelay
Delay size.
Definition: Cayley.h:32
uint64_t rand()
Generate 64 pseudo-random bits.
Definition: Cayley32.cpp:20
The Cayley PRNG.
Definition: Cayley.h:24
uint64_t m_nDelayLine[m_nDelay]
Delay line.
Definition: Cayley.h:34