Documentation ¶
Index ¶
- func BoolP(counter uint64, funcIndex uint32, key uint32, p float32) bool
- func Float32(counter uint64, funcIndex uint32, key uint32) float32
- func Float32Norm(counter uint64, funcIndex uint32, key uint32) float32
- func Float32NormVec2(counter uint64, funcIndex uint32, key uint32) sltype.Float32Vec2
- func Float32Range11(counter uint64, funcIndex uint32, key uint32) float32
- func Float32Range11Vec2(counter uint64, funcIndex uint32, key uint32) sltype.Float32Vec2
- func Float32Vec2(counter uint64, funcIndex uint32, key uint32) sltype.Float32Vec2
- func Philox2x32(counter uint64, key uint32) sltype.Uint32Vec2
- func Philox2x32bumpkey(key uint32) uint32
- func Philox2x32round(counter uint64, key uint32) uint64
- func SincosPi(x float32) sltype.Float32Vec2
- func Uint32(counter uint64, funcIndex uint32, key uint32) uint32
- func Uint32N(counter uint64, funcIndex uint32, key uint32, n uint32) uint32
- func Uint32Vec2(counter uint64, funcIndex uint32, key uint32) sltype.Uint32Vec2
- type Counter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BoolP ¶
BoolP returns a bool true value with probability p based on given global shared counter, function index offset from that counter for this specific random number call, and key as unique index of the item being processed.
func Float32 ¶
Float32 returns a uniformly distributed float32 value in range (0,1), based on given global shared counter, function index offset from that counter for this specific random number call, and key as unique index of the item being processed.
func Float32Norm ¶
Float32Norm returns a random float32 number distributed according to the normal, Gaussian distribution with zero mean and unit variance. Uses given global shared counter, function index offset from that counter for this specific random number call, and key as unique index of the item being processed.
func Float32NormVec2 ¶
func Float32NormVec2(counter uint64, funcIndex uint32, key uint32) sltype.Float32Vec2
Float32NormVec2 returns two random float32 numbers distributed according to the normal, Gaussian distribution with zero mean and unit variance. This is done very efficiently using the Box-Muller algorithm that consumes two random 32 bit uint values. Uses given global shared counter, function index offset from that counter for this specific random number call, and key as unique index of the item being processed.
func Float32Range11 ¶
Float32Range11 returns a uniformly distributed float32 value in range [-1,1], based on given global shared counter, function index offset from that counter for this specific random number call, and key as unique index of the item being processed.
func Float32Range11Vec2 ¶
func Float32Range11Vec2(counter uint64, funcIndex uint32, key uint32) sltype.Float32Vec2
Float32Range11Vec2 returns two uniformly distributed float32 values in range [-1,1], based on given global shared counter, function index offset from that counter for this specific random number call, and key as unique index of the item being processed.
func Float32Vec2 ¶
func Float32Vec2(counter uint64, funcIndex uint32, key uint32) sltype.Float32Vec2
Float32Vec2 returns two uniformly distributed float32 values in range (0,1), based on given global shared counter, function index offset from that counter for this specific random number call, and key as unique index of the item being processed.
func Philox2x32 ¶
func Philox2x32(counter uint64, key uint32) sltype.Uint32Vec2
Philox2x32 implements the stateless counter-based RNG algorithm returning a random number as two uint32 values, given a counter and key input that determine the result.
func Philox2x32bumpkey ¶
Philox2x32bumpkey does one round of updating of the key
func Philox2x32round ¶
Philox2x32round does one round of updating of the counter.
func SincosPi ¶
func SincosPi(x float32) sltype.Float32Vec2
func Uint32 ¶
Uint32 returns a uniformly distributed 32 unsigned integer, based on given global shared counter, function index offset from that counter for this specific random number call, and key as unique index of the item being processed.
func Uint32N ¶
Uint32N returns a uint32 in the range [0,N). Uses given global shared counter, function index offset from that counter for this specific random number call, and key as unique index of the item being processed.
func Uint32Vec2 ¶
func Uint32Vec2(counter uint64, funcIndex uint32, key uint32) sltype.Uint32Vec2
Uint32Vec2 returns two uniformly distributed 32 unsigned integers, based on given global shared counter, function index offset from that counter for this specific random number call, and key as unique index of the item being processed.
Types ¶
type Counter ¶
type Counter struct { // Counter value Counter uint64 // last seed value set by Seed method, restored by Reset() HiSeed uint32 // contains filtered or unexported fields }
Counter is used for storing the random counter using aligned 16 byte storage, with convenience methods for typical use cases. It retains a copy of the last Seed value, which is applied to the Hi uint32 value.
func (*Counter) Add ¶
Add increments the counter by given amount. Call this after completing a pass of computation where the value passed here is the max of funcIndex+1 used for any possible random calls during that pass.
func (*Counter) Seed ¶
Seed sets the Hi uint32 value from given seed, saving it in HiSeed field. Each increment in seed generates a unique sequence of over 4 billion numbers, so it is reasonable to just use incremental values there, but more widely spaced numbers will result in longer unique sequences. Resets Lo to 0. This same seed will be restored during Reset