File: mtrand.c

package info (click to toggle)
gretl 1.3.3-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 20,544 kB
  • ctags: 11,029
  • sloc: ansic: 156,263; xml: 31,443; sh: 8,558; makefile: 1,749; lisp: 1,120; perl: 911
file content (35 lines) | stat: -rw-r--r-- 499 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <stdio.h>
#include <stdlib.h>

#include "libgretl.h"

#define NINTS 2867200

int main (int argc, char *argv[])
{
    int i, seed = 0;
    unsigned r;
    FILE *fp;

    if (argc > 1) {
	seed = atoi(argv[1]);
    } 

    gretl_rand_init();

    if (seed) {
	gretl_rand_set_seed((unsigned) seed);
    }

    fp = fopen("gretl_output.32", "wb");

    for (i=0; i<NINTS; i++) {
	r = gretl_rand_int();
	fwrite(&r, sizeof r, 1, fp);
    }
    fclose(fp);

    gretl_rand_free();

    return 0;
}