Go to the documentation of this file.
   24     typedef unsigned long long u8;
 
   26     u8 
static constexpr rot(u8 x, u8 k) { 
return (((x)<<(k))|((x)>>(64-(k)))); }
 
   28     struct State { u8 a, b, c, d; };
 
   49       state.a = 0xf1ea5eed;  state.b = seed;  state.c = seed;  state.d = seed;
 
   50       for (
int i=0; i<20; ++i) { 
gen(); }
 
   55       u8 e    = state.a - rot(state.b, 7);
 
   56       state.a = state.b ^ rot(state.c,13);
 
   57       state.b = state.c + rot(state.d,37);
 
   58       state.c = state.d + e;
 
   59       state.d = e       + state.a;
 
   66       return static_cast<T
>(
gen()) / 
static_cast<T
>(std::numeric_limits<u8>::max());
 
   74       return genFP<T>() * (ub-lb) + lb;
 
  
YAKL_INLINE Random & operator=(Random const &in)
Copies a Random object.
Definition: YAKL_random.h:43
 
YAKL_INLINE T genFP()
Generates a random floating point value between 0 and 1
Definition: YAKL_random.h:65
 
Non-cryptographic pseudo-random number generator with a very small internal state.
Definition: YAKL_random.h:21
 
YAKL_INLINE u8 gen()
Generates a random unsigned integer between zero and std::numeric_limits<u8>::max() - 1
Definition: YAKL_random.h:54
 
#define __YAKL_NAMESPACE_WRAPPER_END__
Definition: YAKL.h:20
 
YAKL_INLINE Random(Random const &in)
Copies a Random object.
Definition: YAKL_random.h:39
 
#define __YAKL_NAMESPACE_WRAPPER_BEGIN__
Definition: YAKL.h:19
 
#define YAKL_INLINE
Used to decorate functions called from kernels (parallel_for and parallel_outer) or from CPU function...
Definition: YAKL_defines.h:140
 
YAKL_INLINE Random(Random &&in)
Moves a Random object.
Definition: YAKL_random.h:41
 
YAKL_INLINE Random & operator=(Random &&in)
Moves a Random object.
Definition: YAKL_random.h:45
 
YAKL_INLINE T genFP(T lb, T ub)
Generates a random floating point value between lb and ub
Definition: YAKL_random.h:73
 
YAKL_INLINE void set_seed(u8 seed)
Assigns a seed. Warm-up of 20 iterations.
Definition: YAKL_random.h:48
 
YAKL_INLINE Random(u8 seed)
Initializes a prng object with the specified seed. Warm-up of 20 iterations.
Definition: YAKL_random.h:37
 
YAKL_INLINE Random()
Initializes a prng object with the seed 1368976481. Warm-up of 20 iterations.
Definition: YAKL_random.h:35