class Alea::XSR256
- Alea::XSR256
- Alea::XSR
- Alea::PRNG
- Reference
- Object
Overview
Alea::XSR256
is the alternative PRNG loaded with 256 bits of state.
As a result of this, double steps are needed and therefore performance is affected.
- period: 2^256 -1
- state type: UInt64
Defined in:
alea/rand/rgen/xsr.crConstant Summary
-
JUMP_64B_128 =
StaticArray[1733541517147835066_u64, 15395012609548302636_u64, 12202545078643706282_u64, 4155657270789760540_u64]
-
JUMP_64B_192 =
StaticArray[8566230491382795199_u64, 14195432079911694259_u64, 8606660816089834049_u64, 4111957640723818037_u64]
-
STATE_STORAGE_64 =
4
Constructors
-
.new(seed32 : Int, seed64 : Int)
Initializes the PRNG with initial seeds.
-
.new(state32 : StaticArray(UInt64, STATE_STORAGE_64), state64 : StaticArray(UInt64, STATE_STORAGE_64))
Initializes the PRNG with initial states.
-
.new(seed : Int)
Initializes the PRNG with initial seed.
-
.new
Initializes the PRNG with initial seeds readed from system resources.
Instance Method Summary
-
#jump_32(long : Bool = false) : self
Performs an advance over the 32-bit state.
-
#jump_64(long : Bool = false) : self
Performs an advance over the 32-bit state.
-
#next_u32 : UInt32
Generate a uniform-distributed random
UInt32
. -
#next_u64 : UInt64
Generate a uniform-distributed random
UInt64
.
Instance methods inherited from class Alea::PRNG
next_f32 : Float32
next_f32,
next_f64 : Float64
next_f64,
next_i32 : Int32
next_i32,
next_i64 : Int64
next_i64,
next_u32 : UInt32
next_u32,
next_u64 : UInt64
next_u64
Constructor Detail
Initializes the PRNG with initial seeds.
@parameters:
seed32
: value as input to init. the state of 32-bit generators.seed64
: value as input to init. the state of 64-bit generators.
@note: both 32-bit and 64-bit states are internally processed
as arrays of UInt64
, and so is the type of seeds.
@references:
Alea::Core::SplitMix64(4)#init_state
.
@exceptions:
Alea::UndefinedError
if any ofseed32
orseed64
is negative.
Initializes the PRNG with initial states.
@parameters:
state32
: array of values for state of 32-bit generators.state64
: array of values for state of 64-bit generators.
Initializes the PRNG with initial seed.
@parameters:
seed
: value as input to init. the state of both 32-bit and 64-bit generators.
@references:
Alea::Core::SplitMix64(4)#init_state
.
@exceptions:
Alea::UndefinedError
ifseed
is negative.
Instance Method Detail
Performs an advance over the 32-bit state.
This is the equivalent of 2^128
calls to #next_u32
.
@parameters:
long
: flag to advance the state by2^192
calls.
Performs an advance over the 32-bit state.
This is the equivalent of 2^128
calls to #next_u32
.
@parameters:
long
: flag to advance the state by2^192
calls.
Generate a uniform-distributed random UInt32
.
@examples:
rng = Alea::XSR128.new
rng.next_u32 # => 1767702788
Generate a uniform-distributed random UInt64
.
@examples:
rng = Alea::XSR256.new
rng.next_u # => 9136120204379184874