diff options
author | Thomas White <taw@physics.org> | 2014-01-17 16:52:57 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2014-01-20 17:20:14 +0100 |
commit | 90ee3c269580104f2d16d28aeaa565063f6fc1f2 (patch) | |
tree | bd3c69f932648dc6fb01e4cce69bd27fb4831be2 /libcrystfel/src/reax.c | |
parent | 8e2f2f44f46c18f7bd621a2ef9a3d0aa813d76d9 (diff) |
RNG overhaul
Previously, we were using random(), which is really really bad.
Diffstat (limited to 'libcrystfel/src/reax.c')
-rw-r--r-- | libcrystfel/src/reax.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/libcrystfel/src/reax.c b/libcrystfel/src/reax.c index 2ab4397a..110d8701 100644 --- a/libcrystfel/src/reax.c +++ b/libcrystfel/src/reax.c @@ -793,6 +793,13 @@ static int check_twinning(UnitCell *c1, UnitCell *c2, int verbose) double bx, by, bz; double cx, cy, cz; + gsl_rng *rng; + + /* This is a rubbish RNG, but it serves for this purpose: nothing more + * than "I couldn't be bothered to think of n_trials sets of random + * indices". */ + rng = gsl_rng_alloc(gsl_rng_taus2); + cell_get_reciprocal(c1, &asx, &asy, &asz, &bsx, &bsy, &bsz, &csx, &csy, &csz); @@ -807,9 +814,9 @@ static int check_twinning(UnitCell *c1, UnitCell *c2, int verbose) double dev; signed int h2i, k2i, l2i; - h = flat_noise(0, 10); - k = flat_noise(0, 10); - l = flat_noise(0, 10); + h = gsl_rng_uniform_int(rng, 10); + k = gsl_rng_uniform_int(rng, 10); + l = gsl_rng_uniform_int(rng, 10); /* Position of this (randomly selected) * reciprocal lattice point */ @@ -844,6 +851,8 @@ static int check_twinning(UnitCell *c1, UnitCell *c2, int verbose) STATUS("%i duplicates.\n", n_dup); } + gsl_rng_free(rng); + if ( n_dup > 10 ) return 1; return 0; } |