Here's a demo of how to use the mtwist
implementation of Mersenne Twister:
#include <stdio.h>
#include <stdlib.h>
#include "mtwist.h"
int main(void) {
int i;
mt_seed();
for(i = 0; i < 10; ++i) {
printf("%f\n", mt_ldrand());
}
return EXIT_SUCCESS;
}
Compiled and run as follows:
[pjs@amber:mtwist-1.4]$ gcc run-mtwist.c mtwist.c
[pjs@amber:mtwist-1.4]$ ./a.out
0.817330
0.510354
0.035416
0.625709
0.410711
0.980872
0.965528
0.444438
0.705342
0.368748
[pjs@amber:mtwist-1.4]$