Boost logo

Boost :

From: Beman Dawes (beman_at_[hidden])
Date: 1998-12-09 20:31:43


At 07:08 PM 12/9/98 +0000, Kevlin Henney wrote:

>I am not sure that this is a fair characterisation of the algorithm
used,
>which is a linear feedback shift register which has well known
properties
>as a competent and efficient generator. The generator in question
uses a 32
>bit LSFR to produce bits, and so standard usage is to accumulate the
bits
>as necessary to create an integer of the appropriate size: no
revalidation
>is needed for different types if the underlying bit generation is
sound; it
>is needed if you mess with the LSFR size and composition -- no
intention of
>doing that!
>
>The pseudo-container suggestion in the original work proved a point
about
>generated sequences, but is not essential to the random number
issue. I
>prefer the suggestion that a counting adapter, taking begin iterator
and
>count, would be more appropriate as this has general application.
This is
>definitely worth having.
>
>Core to the original work was the idea of generated sequence as
iterator,
>and I think that is the most valuable thing, ie relationship to
iterator
>requirements, etc.
>
>I do not see that having alternative implementations of a random
number
>generator is necessarily a bad thing, esp as the one I was proposing
had
>different usage properties (ie template parameterisation),
performance
>characteristics and explores a different model consistent with other
parts
>of the standard library.
>
>Maybe a suitable area of convergence would be to separate out some
concerns
>and consider this as three separate layers:
>
>* Random number generation, using a generator function conforming to
std
>requirements.

Yes, particularly the requirements for a random number generating
function object in 25.2.11.

>* An adaptor class, templated on (and initialised by an instance of)
a
>random generator type, that allows a generator to be used as a
forward
>iterator to const.

I am unsure if this separate adapter class is needed. Greg Colvin
has said in private email that he thinks the RNG class itself can
model an iterator. That would be simpler if it can be made to work.

>* An adaptor that creates the effect of a pseudo-container by taking
a
>begin iterator and count -- this last is more general purpose.

Yes, that seems would seem to be needed if you want, say, begin() and
end() for 1000 iterators using some specified RNG.

>What do you think?

Give it a try! Put some code together and post it to this mailing
list to see what people think of it. The feedback should be
valuable.

--Beman
------------------------------------------------------------------------
Free Web-based e-mail groups -- http://www.eGroups.com


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk