Skip to content

rand.xoroshiro128pp #

Constants #

const seed_len = 4 // u32, that is

struct XOROS128PPRNG #

struct XOROS128PPRNG {
	buffer.PRNGBuffer
mut:
	state0 u64 = u64(0x853c49e6748fea9b) ^ seed.time_seed_64()
	state1 u64 = u64(0xda3e39cb94b95bdb) ^ seed.time_seed_64()
}

XOROS128PPRNG ported from https://prng.di.unimi.it/xoroshiro128plusplus.c

fn (XOROS128PPRNG) seed #

fn (mut rng XOROS128PPRNG) seed(seed_data []u32)

seed seeds the XOROS128PPRNG with 4 u32 values.

fn (XOROS128PPRNG) u8 #

fn (mut rng XOROS128PPRNG) u8() u8

byte returns a uniformly distributed pseudorandom 8-bit unsigned byte.

fn (XOROS128PPRNG) u16 #

fn (mut rng XOROS128PPRNG) u16() u16

u16 returns a pseudorandom 16-bit unsigned integer (u16).

fn (XOROS128PPRNG) u32 #

fn (mut rng XOROS128PPRNG) u32() u32

u32 returns a pseudorandom unsigned u32.

fn (XOROS128PPRNG) u64 #

fn (mut rng XOROS128PPRNG) u64() u64

u64 returns a pseudorandom 64-bit unsigned u64.

fn (XOROS128PPRNG) block_size #

fn (mut rng XOROS128PPRNG) block_size() int

block_size returns the number of bits that the RNG can produce in a single iteration.

fn (XOROS128PPRNG) free #

unsafe
fn (mut rng XOROS128PPRNG) free()

free should be called when the generator is no longer needed