17 #ifndef __UT_XorShift__
18 #define __UT_XorShift__
38 reseed(seed0, seed1, seed2, seed3);
47 reseed(state[0], state[1]);
56 uint64 seed01 = SYSwang_inthash64(seed0);
59 seed01 = SYSwang_inthash64(seed01);
62 if (seed01 == 0 && state[0] == 0)
65 state[0] = 0xdd8d9063f8c6a49aULL;
66 state[1] = 0x5b3f183183528aaaULL;
78 const uint64 s0 = state[1];
81 s1 = (s1 ^ s0 ^ (s1 >> 17) ^ (s0 >> 26));
90 uint32 temp = state[0] ^ (state[0] << 11);
94 state[3] = state[3] ^ (state[3] >> 19) ^ temp ^ (temp >> 8);
111 int e = SYSlastBitSet(i);
120 int e = SYSlastBitSet(i);
128 uint32 urandom() {
return get(); }
129 float frandom() {
return getFloat(); }
132 uint32 combinedseeds[4] = {0, 0, 0, 0};
134 for (
exint i = 0; i < m; ++i)
135 combinedseeds[i] = seeds[i];
136 for (
exint i = 4; i < nseeds; ++i)
137 combinedseeds[i & 0x3] =
uint32(SYSwang_inthash64((
uint64(seeds[i])<<32) |
uint64(combinedseeds[i & 0x3])));
138 reseed(combinedseeds[0], combinedseeds[1], combinedseeds[2], combinedseeds[3]);
159 reseed(seed0, seed1, seed2, seed3);
178 myCached =
uint32(result >> 32);
SYS_FORCE_INLINE float getFloat()
void reseed(uint64 seed0, uint64 seed1=0)
void reseed(uint64 seed0, uint64 seed1=0)
SYS_FORCE_INLINE void reseedSelf()
SYS_FORCE_INLINE UT_XorShiftCached()
**But if you need a result
unsigned long long uint64
SYS_FORCE_INLINE UT_XorShift(uint32 seed0, uint32 seed1=0, uint32 seed2=0, uint32 seed3=0)
SYS_FORCE_INLINE UT_XorShiftCached(uint64 seed0, uint64 seed1=0)
SYS_FORCE_INLINE UT_XorShiftCached(uint32 seed0, uint32 seed1=0, uint32 seed2=0, uint32 seed3=0)
SYS_FORCE_INLINE void reseed(uint32 seed0, uint32 seed1=0, uint32 seed2=0, uint32 seed3=0)
static SYS_FORCE_INLINE fpreal64 int64ToDouble01(uint64 i)
SYS_FORCE_INLINE void reseed(uint32 seed0, uint32 seed1=0, uint32 seed2=0, uint32 seed3=0)
SYS_FORCE_INLINE float getFloat()
static SYS_FORCE_INLINE fpreal32 intToFloat01(uint32 i)
SYS_FORCE_INLINE UT_XorShift(uint64 seed0, uint64 seed1=0)
SYS_FORCE_INLINE uint64 get64()
SYS_FORCE_INLINE UT_XorShift()
SYS_FORCE_INLINE double getDouble()