![]() |
RandomNumber Class ReferenceThe following class uses an xorshift algorithm proposed in the following paper: More...
Detailed DescriptionThe following class uses an xorshift algorithm proposed in the following paper:The algorithm provides a PRNG with a period of (2^128)-1 This PRNG is *not* intended for cryptographic purposes
Definition at line 40 of file RandomNumber.h. Constructor & Destructor Documentation
Default constructor. NOTE: Internal seeds are set to defaults proposed by the paper Definition at line 34 of file RandomNumber.cpp. References reset(). 00035 :mXSeed(time_shuffle ? (unsigned long)time(NULL) ^ X_SEED_DEFAULT : X_SEED_DEFAULT) 00036 ,mYSeed(time_shuffle ? (unsigned long)time(NULL) ^ Y_SEED_DEFAULT : Y_SEED_DEFAULT) 00037 ,mZSeed(time_shuffle ? (unsigned long)time(NULL) ^ Z_SEED_DEFAULT : Z_SEED_DEFAULT) 00038 ,mWSeed(time_shuffle ? (unsigned long)time(NULL) ^ W_SEED_DEFAULT : W_SEED_DEFAULT) 00039 { 00040 reset(); 00041 }
Member Function Documentation
Cast operator to obtain current random value in the PRNG.
Definition at line 68 of file RandomNumber.cpp. References mW. 00069 { 00070 return(mW); 00071 }
Go to the next number in the PRNG sequence. NOTE: This method is a slightly modified implementation of the xor128() function proposed in the paper
Definition at line 73 of file RandomNumber.cpp. References mW, mX, mY, and mZ. Referenced by skip(), and Utility::u2ip(). 00074 { 00075 register unsigned long int t = (mX ^ (mX<<11)); 00076 00077 mX = mY; 00078 00079 mY = mZ; 00080 00081 mZ = mW; 00082 00083 return(mW = (mW ^ (mW>>19)) ^ (t ^ (t>>8))); 00084 }
Skip ahead in the PRNG sequence by a given number of iterations.
Definition at line 86 of file RandomNumber.cpp. 00087 { 00088 for(register unsigned long int i = 0 ; i < s ; ++i) 00089 { 00090 (void)next(); 00091 } 00092 00093 return(mW); 00094 }
Obtain all the initial seeds for this PRNG.
Definition at line 96 of file RandomNumber.cpp. References mWSeed, mXSeed, mYSeed, and mZSeed. 00101 { 00102 x_seed = mXSeed; 00103 y_seed = mYSeed; 00104 z_seed = mZSeed; 00105 w_seed = mWSeed; 00106 }
Get the maximum possible random number from this PRNG.
Definition at line 108 of file RandomNumber.cpp.
Member Data Documentation
Default x-seed as proposed by the paper.
Definition at line 135 of file RandomNumber.h.
W value. NOTE: This is the externally-visible next value produced by the PRNG Definition at line 193 of file RandomNumber.h. Referenced by next(), operator unsigned long int(), reset(), and skip().
The documentation for this class was generated from the following files: |