On 2014-04-22 10:51, John Salmon wrote:
On Mon, Apr 21, 2014 at 7:51 PM, Steven Watanabe
wrote: AMDG
On 04/21/2014 02:28 PM, John Salmon wrote:
<snip> I would love to see a boost implementation that captured and exposed this capability for general use. Thus, I think a better approach is as follows:
- define a new "RandomFunction" concept that dscribes/enforces the essential, common features of the randomizing function in Threefry, Philox, ARS and other counter-based random generators.
I don't think this is a particularly useful abstraction. Most users should not care at all about this, since they should be using the predefined engine typedefs. If more similar generators are added later, then the implementation can be adjusted to factor out the common boilerplate, but I really don't see the point of creating a whole new concept for this.
I don't think this is a particularly useful abstraction. Most users should not care at all about this, since they should be using the predefined engine typedefs. If more similar generators are added later, then the implementation can be adjusted to factor out the common boilerplate, but I really don't see the point of creating a whole new concept for this.
It may well be true that most users should use a predefined generator because the Engine concept is well matched to the style of random number generator that has been in use for 65 years.
But the question is not whether a RandomFunction abstraction should or would be used by *most* users. The question is whether it's useful to *enough* users.
In case it helps motivate this abstraction, I will mention that I have wanted it in the past. I wanted to generate unpredictable Perlin noise in a game (predictability would in this case allow clients to cheat). For that I wanted exactly a RandomFunction like this which would simply map each integer to an independent random value. This is essentially the same interface Mathias was asking for elsewhere in the thread. What I actually ended up using was a linear congruential generator with O(log(n)) stepping, which didn't satisfactorily achieve any of my design goals. A good random function in Boost.Random would have been perfect. John