From: Thomas Mang (spamfoodaddress_at_[hidden])
Date: 2007-08-21 18:22:48
I came across several issues regarding the [random] - library:
Firstly, at least occassionally the documentation is not fully in synch with the class headers, or at least not in my eyes. Consider the synopsis for variate_generator<>, it misses the "distribution" - member functions (and by the way led me at first sight to use something else because I needed access to the distribution). The functions are mentioned in the description, but IMHO they should definitely also be listed in the synopsis.
Secondly, for lognormal_distribution the return-type for the const member functions mean and sigma is both a reference to non-const RealType, which of course causes a compile-time error on use of these functions (const member functions trying to return reference to non-const data member). This applies to both the docs and the code. Since I cannot imagine a single situation where this function declaration would make sense I suppose it is a mistake, and the return type should be a RealType by value (or ref-to-const), as do the other distributions ?
Thirdly, for the distributions the template parameter "UniformRandomNumberGenerator" is in my eyes underdocumented; I tried the normal_distribution using mt19937 as parameter, just to find out it results in an assert being fired and that apparently a uniform distribution with range 0-1 is required. This again is not obvious, since the documentation lacks a clear mentioning of that (besides the innocent column 'explanation' in the distributions table - at least I didn't find anything; apologize if I have overlooked it), and the template parameter name is also not very descriptive, I could not read from it that the range has to be 0-1 (and with the min / max members of generators it is even less clear to me why it cannot be made use of those to delimit the range automatically).
I guess the same issue applies to other distributions, and maybe does not even always result in an assert being fired.
-- GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS. Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk