pcg

+ A D port of the PCG pseudorandom number generator at http://pcg-random.org + + Most of the functionality is tested against the PCG C++ implementation to ensure + that the output matches. That is, the D generators should produce the same output as the + C++ ones. The exception is default-initialized, unseeded generators, due to D not allowing + a default constructor on structs. + + 64-bit generators are not supported yet, as they require the (currently unsupported) + 128-bit integer types that D has not yet implemented. + + Unique generators are also not supported. Seed with std.random.unpredictableSeed instead.

Members

Aliases

PCG32
alias PCG32 = PCGEngine!(uint, ulong, xsh_rr, true, SetSeq)
PCG32Fast
alias PCG32Fast = PCGEngine!(uint, ulong, xsh_rs, true, MCG)
PCG32OneSeq
alias PCG32OneSeq = PCGEngine!(uint, ulong, xsh_rr, true, OneSeq)

+ Pre-defined PCG generators, matching the original source code's definitions. + + PCG32 support multiple streams, PCG32OneSeq and PCG32Fast do not. PCG32Fast is slightly faster, but has a shorter period.

Functions

rxs
ResultType rxs(StateType state)

Output function RXS -- random xorshift

rxs_m
ResultType rxs_m(StateType state)

+ Output function RXS M -- random xorshift, mcg multiply

rxs_m_xs
ResultType rxs_m_xs(StateType state)

Outpur function RXS M XS -- random xorshift, mcg multiply, fixed xorshift

xsh_rr
ResultType xsh_rr(StateType state)

+ Output function XSH RR -- high xorshift, followed by a random rotate + + Fast. A good performer. Slightly better statistically than XSH RS.

xsh_rs
ResultType xsh_rs(StateType state)

Output function XSH RS -- high xorshift, followed by a random shift

xsl_rr
ResultType xsl_rr(StateType state)

+ Output function XSL RR -- fixed xorshift (to low bits), random rotate + + Useful for 128-bit types that are split across two CPU registers.

Mixin templates

MCG
mixintemplate MCG(StateType)

+ MCG Generator. + + No multi-stream support. Slightly faster, but smaller period.

OneSeq
mixintemplate OneSeq(StateType)

+ OneSeq Generator. + + No multi-stream support.

SetSeq
mixintemplate SetSeq(StateType)

+ SetSeq Generator. + + Has multi-stream support.

Structs

PCGEngine
struct PCGEngine(ResultType, StateType, alias OutputFunc, bool OutputPrevious = true, alias StreamTypeMixin = OneSeq, StateType Multiplier = default_multiplier!StateType)

+ The main PCG engine. + + It takes several configurable parameters.

Meta