I tried searching for examples on how to use the mt19937ar.c variant of Mersenne Twister but most come up in C++ and others seem to use mtwist.h
.
My code below:
int getRandomNum(void)
{
int i;
i = (int) genrand_int32();
return i;
}
int main(int argc, char **argv)
{
...
int m = getRandomNum();
printf("m = %d", m);
...
return 0;
}
simply spits out the same integer over and over again. Seems like a seeding issue, but every implementation that I've found of getting a random number with mt19937
simply just invokes genrand_int32()
. Am I doing this incorrectly?
Aucun commentaire:
Enregistrer un commentaire