This is the mail archive of the
gsl-discuss@sourceware.org
mailing list for the GSL project.
Re: rng question
No, the attached program does not return from the call to
gsl_rng_uniform_int.
The problem shows up on my powermac running MacOSX 10.4.3 with gcc
version powerpc-apple-darwin8-gcc-4.0.0 (GCC) 4.0.0 20041026 (Apple
Computer, Inc. build 4061).
I compile GSL from CVS (20051208 = today) with with flags -NDEBUG -O2.
The test program is compiled with a plain 'gcc -o rnd_test rnd_test.c
-lgsl'.
Now, I also run the test program on a SuSE based machine, and the call
fails with an floating point exception as expected.
Jari
Brian Gough wrote:
Jari Häkkinen writes:
> According to the documentation gsl_rng_max(rng_ returns the maximum
> random number the underlying rng can give, and
> gsl_rng_uniform_int(rng,gsl_rng_max(rng)) will return
> [0,gsl_rng_max(rng)-1]. This will not give the maximum number from the
> underlying generator, so I tried
> gsl_rng_uniform_int(rng,gsl_rng_max(rng)+1) but this call does not
> return (since the second argument becomes 0).
Doesn't it give an exception? (due to division by zero in the expression scale = range / n;)
What platform are you using?
#include <gsl/gsl_rng.h>
int main(const int argc,const char* argv[])
{
gsl_rng_env_setup();
gsl_rng* rng=gsl_rng_alloc(gsl_rng_default);
unsigned long max=gsl_rng_max(rng);
printf("%u\n",max+1);
unsigned long number=gsl_rng_uniform_int(rng,max+1);
printf("%u\n",number);
}