Documentation
¶
Overview ¶
Package xorshift128plus provides implementation for xorshift PRNG algorithm with addition as the non-linear transformation function.
References:
http://xoroshiro.di.unimi.it/ http://xoroshiro.di.unimi.it/xorshift128plus.c
Index ¶
- type Xorshift128Plus
- func (x *Xorshift128Plus) Float64() float64
- func (x *Xorshift128Plus) Float64OO() float64
- func (x *Xorshift128Plus) GetSeed() uint64
- func (x *Xorshift128Plus) GetState() []byte
- func (x *Xorshift128Plus) Reset()
- func (x *Xorshift128Plus) Seed(seed uint64)
- func (x *Xorshift128Plus) SetState(b []byte)
- func (x *Xorshift128Plus) Uint64() uint64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Xorshift128Plus ¶
type Xorshift128Plus struct {
// contains filtered or unexported fields
}
Xorshift128Plus implements a Xorshift PRNG with 128 bits of state and a maximal period of 2^128-1. The algorithm uses addition as the non-linear transformation function
func New ¶
func New(seed uint64) *Xorshift128Plus
New returns a new instance of the Xorshift128Plus PRNG Engine. If the seed provided is 0, the engine is initialized with current time
func (*Xorshift128Plus) Float64 ¶
func (x *Xorshift128Plus) Float64() float64
Float64 returns a pseudo-random number in [0.0, 1.0) as a float64. Float64 advances the internal state of the engine.
func (*Xorshift128Plus) Float64OO ¶
func (x *Xorshift128Plus) Float64OO() float64
Float64OO returns a pseudo-random number in (0.0, 1.0) as a float64. Float6400 advances the internal state of the engine.
func (*Xorshift128Plus) GetSeed ¶
func (x *Xorshift128Plus) GetSeed() uint64
GetSeed returns the seed used to initialize the engine
func (*Xorshift128Plus) GetState ¶
func (x *Xorshift128Plus) GetState() []byte
GetState returns the internal state of the engine as []byte GetState can be used to save the state, e.g. to a file
func (*Xorshift128Plus) Reset ¶
func (x *Xorshift128Plus) Reset()
Reset reverts the internal state of the engine to its default state, except the seed
func (*Xorshift128Plus) Seed ¶
func (x *Xorshift128Plus) Seed(seed uint64)
Seed uses the provided value to initialize the engine
func (*Xorshift128Plus) SetState ¶
func (x *Xorshift128Plus) SetState(b []byte)
SetState sets the internal state of the engine from a []byte SetState can be used to resume from a saved state
func (*Xorshift128Plus) Uint64 ¶
func (x *Xorshift128Plus) Uint64() uint64
Uint64 returns a pseudo-random 64-bit value in [0, 2^64) as a uint64. Uint64 advances the internal state of the engine.