29 mt->
um=UINT64_C(0xFFFFFFFF80000000);
30 mt->
lm=UINT64_C(0x7FFFFFFF);
46#if defined HAVE_TIMESPEC_GET
48 timespec_get(&ts, TIME_UTC);
49 li=((ts.tv_sec % 10000)*523 ^ ts.tv_nsec*10) ^ ((getpid() % 1000)*983);
50#elif defined HAVE_CLOCK_GETTIME
52 clock_gettime(CLOCK_REALTIME, &ts);
53 li=((ts.tv_sec % 10000)*523 ^ ts.tv_nsec*10) ^ ((getpid() % 1000)*983);
54#elif defined HAVE_GETTIMEOFDAY
57 li=((tv.tv_sec % 10000)*523 ^ tv.tv_usec*13) ^ ((getpid() % 1000)*983);
59 li=(
unsigned int)time(NULL)+(
unsigned int)getpid();
77 lli=li; lli<<=32; lli+=li;
100 (UINT64_C(6364136223846793005)*(mt->
mt[mt->
mti-1] ^ (mt->
mt[mt->
mti-1]>>62)) + mt->
mti);
122 i=1; j=0;
if(mt->
n>key_length) k=mt->
n;
else k=key_length;
125 (mt->
mt[i] ^ ((mt->
mt[i-1] ^ (mt->
mt[i-1]>>62)) * UINT64_C(3935559000370003845)))
128 if(i>=mt->
n) {mt->
mt[0]=mt->
mt[mt->
n-1]; i=1;}
129 if(j>=key_length) j=0;
131 for(k=mt->
n-1; k; k--) {
133 (mt->
mt[i] ^ ((mt->
mt[i-1] ^ (mt->
mt[i-1] >> 62)) * UINT64_C(2862933555777941757)))
136 if(i>=mt->
n) {mt->
mt[0]=mt->
mt[mt->
n-1]; i=1;}
138 mt->
mt[0] = UINT64_C(1) << 63;
165 for(i=0; i<mt->
n-mt->
m; i++) {
166 x=(mt->
mt[i]&mt->
um)|(mt->
mt[i+1]&mt->
lm);
167 mt->
mt[i] = mt->
mt[i+mt->
m] ^ (x>>1) ^ mag01[(
int)(x&UINT64_C(1))];
169 for(; i<mt->
n-1; i++) {
170 x = (mt->
mt[i]&mt->
um)|(mt->
mt[i+1]&mt->
lm);
171 mt->
mt[i] = mt->
mt[i+(mt->
m-mt->
n)] ^ (x>>1) ^ mag01[(int)(x&UINT64_C(1))];
173 x = (mt->
mt[mt->
n-1]&mt->
um)|(mt->
mt[0]&mt->
lm);
174 mt->
mt[mt->
n-1] = mt->
mt[mt->
m-1] ^ (x>>1) ^ mag01[(
int)(x&UINT64_C(1))];
179 x ^= (x>>29) & UINT64_C(0x5555555555555555);
180 x ^= (x<<17) & UINT64_C(0x71D67FFFEDA60000);
181 x ^= (x<<37) & UINT64_C(0xFFF7EEE000000000);
290 double dif, v, stl, stu;
293 if(mt==NULL || d==NULL || type<0 || type>1)
return(1);
295 dif=up-low;
if(dif<0.0)
return(2);
297 for(i=0; i<nr; i++) d[i]=low;
304 stl=copysign(sqrt(fabs(low)),low);
if(!isnormal(stl)) stl=0.0;
305 stu=copysign(sqrt(fabs(up)), up);
if(!isnormal(stu)) stu=0.0;
307 for(i=0; i<nr; i++) {
337 return(-
mean*log(r));
369 double fac, rsq, a, b;
377 }
while (rsq>1.0 || rsq==0.0);
379 fac = sqrt(-2.0*log(rsq)/rsq);
Header file for libtpcmodel.
#define TPCCLIB_MERTWI_NN
int mean(double *x, double *y, int nr, double *xmean, double *xsd, double *ymean, double *ysd)
int mertwiRandomBetween(MERTWI *mt, unsigned int nr, double *d, double low, double up, int type)
Fill the given double array with random numbers with uniform distribution between the specified limit...
uint64_t mertwiRandomInt64(MERTWI *mt)
Generate a random number on [0, 2^64-1]-interval using Mersenne Twister MT19937.
void mertwiInitWithSeed64(MERTWI *mt, uint64_t seed)
Initialize the state vector mt[] inside data struct for Mersenne Twister MT19937 pseudorandom number ...
double mertwiRandomDouble1(MERTWI *mt)
Generate a 64-bit double precision floating point pseudorandom number in the range of [0,...
void mertwiInitByArray64(MERTWI *mt, uint64_t init_key[], uint64_t key_length)
Initialize the state vector mt[] inside data struct for Mersenne Twister MT19937 pseudorandom number ...
double mertwiRandomGaussian(MERTWI *mt)
Generate a 64-bit double precision floating point pseudorandom number in the range of [0,...
double mertwiRandomExponential(MERTWI *mt, double mean)
Generate pseudo-random number with exponential distribution and specified mean.
uint64_t mertwiSeed64(void)
Make uint64_t seed for pseudorandom number generators.
double mertwiRandomDouble2(MERTWI *mt)
Generate a 64-bit double precision floating point pseudorandom number in the range of [0,...
void mertwiInit(MERTWI *mt)
int64_t mertwiRandomInt63(MERTWI *mt)
Generate a random number on [0, 2^63-1]-interval using Mersenne Twister MT19937.
double mertwiRandomDouble3(MERTWI *mt)
Generate a 64-bit double precision floating point pseudorandom number in the range of (0,...
uint32_t mertwiSeed32(void)
Make uint32_t seed for pseudorandom number generators.
uint64_t mt[TPCCLIB_MERTWI_NN]