[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-gsl] initialisation of random number generator on 64bit machine

From: Vito Trianni
Subject: [Bug-gsl] initialisation of random number generator on 64bit machine
Date: Wed, 03 Sep 2008 15:43:33 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20080313 Iceape/1.1.9 (Debian-1.1.9-5)

I noticed the following behaviour when initialising the random number generator on a 64bit machine. Basically, on a 64 bit machine, the unsigned long int probably provokes an overflow in the gsl_rng_set() function, so that the initialisation of the seed in some way fails, and I got always identical numbers despite different seeds. Here is part of the code that made the overflow:

unsigned long int un_seed = GetSomeSeed(); // this function returns a random number in [0,ULONG_MAX]

T = gsl_rng_default;
gsl_rng* r = gsl_rng_alloc ( T );
gsl_rng_set ( r, un_seed );    // here probably the overflow

int value = gsl_rng_uniform_int(r, 1000); // retruns always the same number, despite different seeds

For the time being, I bypassed the problem by limiting the seed to UINT_MAX, which does not produces overflows on the 64bit machines.
I hope this report is useful....


Vito Trianni, Ph.D.                  vito.trianni@(no_spam)istc.cnr.it
CNR-ISTC                             http://iridia.ulb.ac.be/~vtrianni
via San Martino della Battaglia, 44     
00185 Roma                           Tel: +39 06 44595 215
Italy                                Fax: +39 06 44595 243

reply via email to

[Prev in Thread] Current Thread [Next in Thread]