aboutsummaryrefslogtreecommitdiff
path: root/tests/integration_check.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2014-01-17 16:52:57 +0100
committerThomas White <taw@physics.org>2014-01-20 17:20:14 +0100
commit90ee3c269580104f2d16d28aeaa565063f6fc1f2 (patch)
treebd3c69f932648dc6fb01e4cce69bd27fb4831be2 /tests/integration_check.c
parent8e2f2f44f46c18f7bd621a2ef9a3d0aa813d76d9 (diff)
RNG overhaul
Previously, we were using random(), which is really really bad.
Diffstat (limited to 'tests/integration_check.c')
-rw-r--r--tests/integration_check.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/tests/integration_check.c b/tests/integration_check.c
index f1b5384b..0196742f 100644
--- a/tests/integration_check.c
+++ b/tests/integration_check.c
@@ -43,7 +43,7 @@ int main(int argc, char *argv[])
struct image image;
int fs, ss;
FILE *fh;
- unsigned int seed;
+ unsigned long int seed;
int fail = 0;
const int w = 128;
const int h = 128;
@@ -57,11 +57,14 @@ int main(int argc, char *argv[])
int i;
Histogram *hi;
double esd_sum = 0.0;
+ gsl_rng *rng;
+
+ rng = gsl_rng_alloc(gsl_rng_mt19937);
fh = fopen("/dev/urandom", "r");
fread(&seed, sizeof(seed), 1, fh);
fclose(fh);
- srand(seed);
+ gsl_rng_set(rng, seed);
image.flags = NULL;
image.beam = NULL;
@@ -110,7 +113,7 @@ int main(int argc, char *argv[])
for ( fs=0; fs<w; fs++ ) {
for ( ss=0; ss<h; ss++ ) {
- image.dp[0][fs+w*ss] = 10.0*poisson_noise(40);
+ image.dp[0][fs+w*ss] = 10.0*poisson_noise(rng, 40);
if ( (fs-64)*(fs-64) + (ss-64)*(ss-64) > 2 ) continue;
//image.dp[0][fs+w*ss] += 10.0*poisson_noise(10);
}
@@ -124,7 +127,7 @@ int main(int argc, char *argv[])
cell_set_centering(cell, 'P');
cell_set_parameters(cell, 800.0e-10, 800.0e-10, 800.0e-10,
deg2rad(90.0), deg2rad(90.0), deg2rad(90.0));
- cell = cell_rotate(cell, random_quaternion());
+ cell = cell_rotate(cell, random_quaternion(rng));
ic.halfw = ir_out;
ic.image = &image;