A Tausworthe random number generator
terchestor
terchestor at gmail.com
Tue Jan 21 08:48:43 PST 2014
On Tuesday, 21 January 2014 at 13:44:09 UTC, monarch_dodra wrote:
> On Tuesday, 21 January 2014 at 11:04:13 UTC, terchestor wrote:
> My major points would be:
> 1) Make it a "final class": By default, classes have all their
> methods virtual. I don't think you want that.
You're right.
> 2) I'd adhere to the "Range" interface: Give your function the
> "front"/"popFront()" functions, as well as the public "enum
> empty = false".
That's and excellent idea because your final example is what I
had in mind.
> 3) I think the *instance* itself should carry the bounds on
> initialization, and provide a single "uniform" function.
There is a later version with only one uniform method. But I'd
like to be able to change bounds with a single instance.
> 4) Uniform initialization: provide a "tausworthe(I = int, R =
> double)(int seed, double low = 0.0, double high = 1.0 )"
> function. This function should simply return a new instance of
> a Tausworthe. The advantage of this are 2-fold:
> 4.1) Similar syntax for struct/class initialization
> 4.2) Default Type parameters for the type.
Excellent, as I said.
> The combination of 2/3/4 will allow you to write nifty things
> like:
> int[] myRandomNumbers = tausworthe(randomSeed).take(10).array();
>
> And voila! An array of 10 random numbers! Easy-peasy.
I adhere.
Thanks for taking time to review first D try.
More information about the Digitalmars-d
mailing list