extern "C" void RandomRef(
    float *h_Random,
    int NPerRng,
    unsigned int seed
){
    int iRng, iOut;

    for(iRng = 0; iRng < MT_RNG_COUNT; iRng++){
        MT[iRng].state = state;
        sgenrand_mt(seed, &MT[iRng]);

        for(iOut = 0; iOut < NPerRng; iOut++)
           h_Random[iRng * NPerRng + iOut] = ((float)genrand_mt(&MT[iRng]) + 1.0f) / 4294967296.0f;
    }
}
Beispiel #2
0
int main(void)
{
    int i,j;
    mt_struct *mts;

    init_dc(4172);

    /* This trys to find a small Mersenne Twister with period 2^521-1. */
    mts = get_mt_parameter(32,521); 
    if (mts == NULL) {
	printf ("error\n");
    }
    else {
	sgenrand_mt(3241, mts);
	for (i=0; i<100; i++) {
	    for (j=0; j<5; j++)
		printf("%8x ", genrand_mt(mts));
	    printf("\n");
	}
	free_mt_struct(mts);
    }

    return 0;
}
Beispiel #3
0
inline static uint32_t dcmt_rand32 (void)
{
    return genrand_mt(dcmt);
}
Beispiel #4
0
bool RandomNextBool(Random rnd) {
	return genrand_mt(rnd) % 2;
}
Beispiel #5
0
int RandomNextIntUntil(Random rnd, uint32 n) {
	return genrand_mt(rnd) % n;
}
Beispiel #6
0
// random double in [0.0,1.0) (0.0 inclusive, 1.0 exclusive)
double RandomNextDouble(Random rnd) {
	return ((double)genrand_mt(rnd) / ((double)(UINT32_MAX) + 1.0));
}
Beispiel #7
0
// random integer between 0 and UINT32_MAX inclusive
uint32 RandomNextInt(Random rnd) {
	return genrand_mt(rnd);
}