Warren Weckesser wrote:
This has nothing to do with threads. Check this out:
----------
#include <stdio.h>
#include <gsl/gsl_rng.h>
int main (void)
{
const gsl_rng_type * T;
gsl_rng *r1, *r2, *r3;
int i, n = 10;
gsl_rng_env_setup();
T = gsl_rng_ranlxs0;
r1 = gsl_rng_alloc(T);
r2 = gsl_rng_alloc(T);
r3 = gsl_rng_alloc(T);
gsl_rng_set(r1,0);
gsl_rng_set(r2,1);
gsl_rng_set(r3,2);
for (i = 0; i < n; i++)
{
double u1 = gsl_rng_uniform (r1);
double u2 = gsl_rng_uniform (r2);
double u3 = gsl_rng_uniform (r3);
printf ("%.11f %.11f %.11f\n", u1,u2, u3);
}
gsl_rng_free (r1);
gsl_rng_free (r2);
gsl_rng_free (r3);
return 0;
}
----------
Compile and run:
----------
$ gcc gslrngtest.c -lgsl -o gslrngtest
$ ./gslrngtest
0.32085895538 0.32085895538 0.16047435999
0.49408543110 0.49408543110 0.24704271555
0.70446860790 0.70446860790 0.35229921341
0.81177759171 0.81177759171 0.40588879585
0.65004783869 0.65004783869 0.32499593496
0.75581908226 0.75581908226 0.87790954113
0.16959655285 0.16959655285 0.08471691608
0.24530410767 0.24530410767 0.12265205383
0.18674021959 0.18674021959 0.59334981441
0.62624281645 0.62624281645 0.31312137842
$
----------
My guess as to why the first two columns are the same is based on this
quote from the docs:
"If the seed s is zero then the standard seed from the original
implementation is used instead."
Perhaps the "standard seed from the original implementation" of ranlxs0
algorithm is 1.
Warren
Thanks Warren, I now remember that I had read somewhere in the
documentation that seed=0 gives the default seed, so I should have
suspected something. When I seed with 1,2,3... I get different results
in each thread for all the different RNGs that I am trying.
Thanks,
Torquil Soerensen
_______________________________________________
Help-gsl mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gsl