This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [gfortran] PATCH -- Fix for PR 15619


On Thu, May 27, 2004 at 12:12:59AM +0100, Paul Brook wrote:
> 
> No, still wrong. Fails the test appended to this mail.
> 
> Possible solution: add an extra word to the seed which contains the current 
> position. Obviously you'll need to cope with arbitary values when the user 
> specifies PUT=, but curent_index=abs(current_index) % N should do the trick.
> 
> Oh, and while you're at it, please rename the global variable "i" to
> something more sane ;)
> 

Sigh.  I really didn't want to become an expert on PRNG.  I only
want to use them. :-)  So, here's my current solution.

See the attached diff.  It replaces the Mersenne Twister with
Marsaglia's KISS PRNG.  I left Lars' code in random.c where I
simply enclosed it in an #if 0 ... #endif.  KISS seems to fix
PR 15619, the code I elided from this email, and the seeding
problem I discuss in other emails.  I've retained Lars'
function names of prefix(random_r4), prefix(arandom_r4),
prefix(random_r8), and  prefix(arandom_r8); although I think
the names should be more descriptivei, e.g., prefix(random_number_r4)
and prefix(random_number_array_r4).  This will allow Lars or somone
else to continue hacking on the Mersenne Twister without changing the API.

2004-05-26  Steven G. Kargl  <kargls@comcast.net>

   * random.c: Replace Mersenne Twister with Marsaglia's KISS PRNG
     (kiss_random_kernel): New function.
     (random_r4,random_r8): Use it.
     (random_seed,arandom_r4,arandom_r8): Update to KISS

-- 
Steve

Attachment: random.c.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]