[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
Re: YARQ - Yet Another Random Query
> Yes, I looked at the man pages, initstate and setstate do not
> help, there is not getstate !!! :-(((..
You don't need a separate getstate as initstate and setstate return a
pointer to the previous state array. But there are caveats tho'.
The RNG does not make a copy of the passed state array; all state
changes are recorded in place. This won't make a difference when you
are using two different arrays to set state from, but if you want
to restore to a previous state along a sequence, you'd be better off
making a copy. Which means you need to know the length of the array.
Storing the pointer also means that you should put state arrays passed to setstate or
initstate in non-local storage; else you'll be doing something akin to
returning a pointer to a local variable.
As regards being able to restore state using the seed value alone, the
RNG used by random () uses the state array in addition to the seed to
drive its beaviour; the array is modified on every call to random ().
The array is a multi-dimensional seed, in some sense.
Venkatesha Murthy G.