Re: Random Numbers



Steven G. Kargl <kargl@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

[ wants random numbers reproducible from run to run ]
OTOH, I do use code of the form

call random_seed(size=n)
allocate(put(n))
put = nrand + 37 * (/ (i - 1, i = 1, n) /) ! nrand is user input.
call random_seed(put=put)
deallocate(put)

Does the standard specify what you can or cannot pass to
random_seed(put=) ? I mean the content, not just the size. I was
bitten once by an implementation that was very picky about the
contents of its seed vectors. I did as you show, asking random_seed()
for the size and filling the array with some sequence salted by a
small user input. The resulting sequence was anything but random !

IIRC the standard promises that you can call random_seed(get=) and
use the result in a random_seed(put=), but as far as I know you
can't construct your own seed.


--
pa at panix dot com
.



Relevant Pages

  • Re: Employer looking 4 online C++ aptitude tests; recommendations?
    ... Undefined behaviour ... >OTOH, this is clearly a better test than the commercial ones I've seen. ... bool is defined by the standard to be "an integral type". ... Does the standard specify what the integral value of "true" should be? ...
    (comp.lang.cpp)
  • Re: Random Numbers
    ... OTOH, I do use code of the form ... Does the standard specify what you can or cannot pass to ... run into a quality of implementation problem with the compiler ...
    (comp.lang.fortran)