[libgfortran,patch] Scramble bytes in the user-provided random seeds (PR 32812)
FX Coudert
fxcoudert@gmail.com
Mon Feb 25 12:01:00 GMT 2008
Hi all,
Current library implementation of RANDOM_NUMBER() is such that the
highest bits of the user-provided seed determine the mots significant
bits of floating-points values return, and the lowest bits of the
seed control the least significant bits of fp values. Thus, a user
providing us with a seed with good lower bits but poor higher bits
will find that the fp values are not very random at all... one such
example being the use of DATE_AND_TIME to provide for random seeds.
This patch adds a little to the quality of implementation by adding a
(bijective) scrambling operation between the seed the user gives us
and the seed we actually use. Two functions, scramble_seed and
unscramble_seed, are used when RANDOM_NUMBER() is called with a PUT=
or GET= argument, which shuffles bytes of the seed.
Regtested on x86_64-linux, with both -m32 and -m64. Tested manually
with different seeds of different qualities.
FX
PS: Of course, we're not adding quality to poor seeds (I'm not
changing entropy with a bijective function!). We're just providing a
little invisible help to one particular case of half-bad, half-good
seeds.
--
François-Xavier Coudert
http://www.homepages.ucl.ac.uk/~uccafco/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: random.ChangeLog
Type: application/octet-stream
Size: 280 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080225/33740a59/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: random.diff
Type: application/octet-stream
Size: 2540 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080225/33740a59/attachment-0001.obj>
More information about the Fortran
mailing list