The OpenD Programming Language

mir.random.engine.pcg

Permuted Congruential Generator (PCG)

Implemented as per the C++ version of PCG, .

Paper available

Members

Aliases

pcg128_oneseq_once_insecure
alias pcg128_oneseq_once_insecure = PermutedCongruentialEngine!(rxs_m_xs_forward!(ucent, ucent), stream_t.specific, true)

ditto Requires ucent type.

pcg16_once_insecure
alias pcg16_once_insecure = PermutedCongruentialEngine!(rxs_m_xs_forward!(ushort, ushort), stream_t.specific, true)

PCGs with n bits output and n bits of state.

pcg16_oneseq_once_insecure
alias pcg16_oneseq_once_insecure = PermutedCongruentialEngine!(rxs_m_xs_forward!(ushort, ushort), stream_t.oneseq, true)

As above but the increment is not dynamically setable.

pcg32
alias pcg32 = PermutedCongruentialEngine!(xsh_rr!(uint, ulong), stream_t.specific, true)
pcg32_fast
alias pcg32_fast = PermutedCongruentialEngine!(xsh_rr!(uint, ulong), stream_t.none, true)

32-bit output PCGs with 64 bits of state.

pcg32_once_insecure
alias pcg32_once_insecure = PermutedCongruentialEngine!(rxs_m_xs_forward!(uint, uint), stream_t.specific, true)

PCGs with n bits output and n bits of state.

pcg32_oneseq
alias pcg32_oneseq = PermutedCongruentialEngine!(xsh_rr!(uint, ulong), stream_t.oneseq, true)

32-bit output PCGs with 64 bits of state.

pcg32_oneseq_once_insecure
alias pcg32_oneseq_once_insecure = PermutedCongruentialEngine!(rxs_m_xs_forward!(uint, uint), stream_t.oneseq, true)

As above but the increment is not dynamically setable.

pcg32_unique
alias pcg32_unique = PermutedCongruentialEngine!(xsh_rr!(uint, ulong), stream_t.unique, true)

32-bit output PCGs with 64 bits of state.

pcg64
alias pcg64 = PermutedCongruentialEngine!(xsh_rr!(ulong, ucent), stream_t.specific, true)

64-bit output PCGs with 128 bits of state. Requires ucent type.

pcg64_fast
alias pcg64_fast = PermutedCongruentialEngine!(xsh_rr!(ulong, ucent), stream_t.none, true)
pcg64_once_insecure
alias pcg64_once_insecure = PermutedCongruentialEngine!(rxs_m_xs_forward!(ulong, ulong), stream_t.specific, true)

PCGs with n bits output and n bits of state.

pcg64_oneseq
alias pcg64_oneseq = PermutedCongruentialEngine!(xsh_rr!(ulong, ucent), stream_t.oneseq, true)
pcg64_oneseq_once_insecure
alias pcg64_oneseq_once_insecure = PermutedCongruentialEngine!(rxs_m_xs_forward!(ulong, ulong), stream_t.oneseq, true)

As above but the increment is not dynamically setable.

pcg64_unique
alias pcg64_unique = PermutedCongruentialEngine!(xsh_rr!(ulong, ucent), stream_t.unique, true)
pcg8_once_insecure
alias pcg8_once_insecure = PermutedCongruentialEngine!(rxs_m_xs_forward!(ubyte, ubyte), stream_t.specific, true)

PCGs with n bits output and n bits of state.

pcg8_oneseq_once_insecure
alias pcg8_oneseq_once_insecure = PermutedCongruentialEngine!(rxs_m_xs_forward!(ubyte, ubyte), stream_t.oneseq, true)

As above but the increment is not dynamically setable.

Enums

stream_t
enum stream_t

Select the above mixin templates.

Functions

rxs
O rxs(Uint state)

RXS -- random xorshift

rxs_m_xs_forward
O rxs_m_xs_forward(Uint state)
rxs_m_xs_reverse
O rxs_m_xs_reverse(Uint state)

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

unxorshift
Uint unxorshift(Uint x, size_t bits, size_t shift)

XorShifts are invertible, but they are someting of a pain to invert. This function backs them out. It's used by the whacky "inside out" generator defined later.

xsh
O xsh(Uint state)

XSH -- fixed xorshift (to high bits)

xsh_rr
O xsh_rr(Uint state)

XSH RR -- high xorshift, followed by a random rotate

xsh_rs
O xsh_rs(Uint state)

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

xsl
O xsl(Uint state)

XSL -- fixed xorshift (to low bits)

xsl_rr
O xsl_rr(Uint state)

XSL RR -- fixed xorshift (to low bits), random rotate

xsl_rr_rr
O xsl_rr_rr(Uint state)

XSL RR RR -- fixed xorshift (to low bits), random rotate (both parts)

Mixin templates

no_stream
mixintemplate no_stream(Uint)

Increment is 0. The LCG portion of the PCG is an MCG.

oneseq_stream
mixintemplate oneseq_stream(Uint)

Increment of the LCG portion of the PCG is default_increment.

specific_stream
mixintemplate specific_stream(Uint)

The increment is dynamically settable and defaults to default_increment!T.

unique_stream
mixintemplate unique_stream(Uint)

Increment for LCG portion of the PCG is the address of the RNG

Structs

PermutedCongruentialEngine
struct PermutedCongruentialEngine(alias output, stream_t streamType, bool output_previous, mult_...)

The PermutedCongruentialEngine:

Meta

Authors

Melissa O'Neill (C++). D translation Nicholas Wilson.

PCG Random Number Generation for C++

Copyright 2014 Melissa O'Neill <oneill@pcg-random.org>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

For additional information about the PCG random number generation scheme, including its license and other licensing options, visit