Module rand.mt19937 stdlib

rand.mt19937
Version:
0.3.3
License:
MIT
Dependencies from vmod:
0
Imports:
2
Imported by:
0
Repository:
OS-specific
Show selected OS-specific symbols.
Backend-specific
Show selected Backend-specific symbols.

Dependencies defined in v.mod

This section is empty.

Imports

Imported by

This section is empty.

Aliases

This section is empty.

Constants

#constant seed_len

pub const seed_len = 2

Sum types

This section is empty.

Functions

This section is empty.

Structs

#struct MT19937RNG

pub struct MT19937RNG {
	buffer.PRNGBuffer
mut:
	state []u64 = get_first_state(seed.time_seed_array(2))
	mti   int   = mt19937.nn
}

MT19937RNG is generator that uses the Mersenne Twister algorithm with period 2^19937.

NOTE: The RNG is not seeded when instantiated so remember to seed it before use.

#fn (&MT19937RNG) seed

fn (mut rng &MT19937RNG) seed(seed_data []u32)

seed sets the current random state based on seed_data.

seed expects seed_data to be only two u32s in little-endian format as [lower, higher].

#fn (&MT19937RNG) u8

inline
fn (mut rng &MT19937RNG) u8() u8

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

#fn (&MT19937RNG) u16

inline
fn (mut rng &MT19937RNG) u16() u16

u16 returns a pseudorandom 16bit int in range [0, 2¹⁶).

#fn (&MT19937RNG) u32

inline
fn (mut rng &MT19937RNG) u32() u32

u32 returns a pseudorandom 32bit int in range [0, 2³²).

#fn (&MT19937RNG) u64

direct_array_accessinline
fn (mut rng &MT19937RNG) u64() u64

u64 returns a pseudorandom 64bit int in range [0, 2⁶⁴).

#fn (&MT19937RNG) block_size

inline
fn (mut rng &MT19937RNG) block_size() int

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

#fn (&MT19937RNG) free

unsafe
fn (mut rng &MT19937RNG) free()

free should be called when the generator is no longer needed

Interfaces

This section is empty.

Enums

This section is empty.