|
Boost : |
From: Jens Maurer (Jens.Maurer_at_[hidden])
Date: 2001-03-30 03:13:54
nbecker_at_[hidden] wrote:
> 2. Generators are bound to transformations by making the
> transformation class a template class with the underlying rng type as a
> paramater. The rng ref is then passed to the constructor.
> Arguably, it is preferrable to defer the binding until it is
> finally needed. This means the operator() is a template member
> which takes the rng& as an argument.
- You may want to use different types for a given distribution
(transformation, as you call it) depending on the underlying generator.
This is not exploited in the current code, but the implementation
option is available.
- If operator() takes the generator as an argument, the distribution
cannot hold any information about the generator. For example, the
distribution may want to pre-compute a few constants/parameters
which depend on the parameters of the underlying generator.
- If operator() takes the generator as an argument, the functor
is, technically speaking, a unary function and not a nullary functor
(i.e. Generator as per STL). This prevents passing such a generator
to std::generate() (or, more precisely, a substitute of that which
takes a reference instead of a value parameter for the Generator).
> 3. I don't understand the use of generator_iterator_mixin_adapter. It
> appears that it's purpose is to give the random generator iterator
> semantics?
Yes.
> If this is true, it's not clear to me why this is
> important.
This was the wish of several of the reviewers, who felt that viewing
a random number generating class as an iterator was an important
feature.
The generator_iterator_mixin_adapter was the quickest and least-
intrusive way for me to implement that wish. It's an implementation
detail anyway.
With the iterator adaptor library available, I should probably
reconsider the implementation choice.
Jens Maurer
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk