-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi-ov.c
84 lines (72 loc) · 1.97 KB
/
api-ov.c
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
* Test of dSFMT and ranlux APIs.
* Dario Mapelli, [email protected]
* Simplest possible program
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include "ranlxd.h"
#include "dSFMT.h"
#include "dSFMT-api.h"
#include "ranlux-api.h"
int main (int numArg, char * listArg[])
{
printf( "Simple dSFMT and ranlux usage\n\n" ) ;
// parameters setting
int rand_length = 10 ;
//all the generated numbers are copied here, otherwise (if -O3 is chosen)
//the compiler undestands that they are not saved anywhere nor printed and
//the output_file binary doesnt contain the code to generate them
double *ranlux_storage = (double*) malloc (sizeof(double)*rand_length) ;
int i=0;
for (i=0; i<rand_length; i++) {
ranlux_storage[i] = -1.;
}
double *dsfmt_storage = (double*) malloc (sizeof(double)*rand_length) ;
for (i=0; i<rand_length; i++) {
dsfmt_storage[i] = -1.;
}
//this is the array that will be used to generate the random numbers
double *rand_arr;
// ranlux
// alloc_ranlux (&rand_arr, rand_length) ;
// ranlxd(rand_arr, rand_length) ;
int ranlux_check = ranlux_alloc_fill(&rand_arr, rand_length, time(NULL)) ;
if (ranlux_check == 1) {
exit(EXIT_FAILURE) ;
}
for (i=0; i<rand_length; i++) {
ranlux_storage[i] = rand_arr[i] ;
}
free(rand_arr) ;
// dSFMT
printf("\n");
int size = dsfmt_get_min_array_size();
if (size < rand_length) {
size = rand_length;
}
int dSFMT_check = dSFMT_alloc_fill(&rand_arr, size, time(NULL));
if (dSFMT_check == 1) {
exit(EXIT_FAILURE) ;
}
for (i=0; i<rand_length; i++) {
dsfmt_storage[i] = rand_arr[i] ;
}
free(rand_arr) ;
printf("\n");
printf("ranlux\n");
for (i=0; i<rand_length; i++) {
printf("%f\n", ranlux_storage[i]) ;
}
printf("\n");
printf("dsfmt\n");
for (i=0; i<rand_length; i++) {
printf("%f\n", dsfmt_storage[i]) ;
}
//Fine Programma
free(ranlux_storage) ;
free(dsfmt_storage) ;
return 0;
}