liba 0.1.15
An algorithm library based on C/C++
Loading...
Searching...
No Matches
pseudorandom number generator
Collaboration diagram for pseudorandom number generator:

Data Structures

struct  a_rand_lcg48
 instance structure for the linear congruential generator and 48-bit integer arithmetic More...

Macros

#define A_RAND_LCG48_INIT   {A_U64_C(0x5DEECE66D), A_U16_C(0xB), {A_U16_C(0x330E), A_U16_C(0xABCD), A_U16_C(0x1234)}}

Typedefs

typedef struct a_rand_lcg48 a_rand_lcg48

Functions

void a_rand_lcg48_init (a_rand_lcg48 *ctx, a_i64 x)
 initialize with a seed value for the linear congruential generator and 48-bit integer arithmetic.
void a_rand_lcg48_seed (a_rand_lcg48 *ctx, a_u16 const x[3])
 initialize with a specific state for the linear congruential generator and 48-bit integer arithmetic.
a_u64 a_rand_lcg48_next (a_rand_lcg48 *ctx, a_u16 x[3])
 perform one iteration for the linear congruential generator and 48-bit integer arithmetic.
a_i32 a_rand_lcg48i (a_rand_lcg48 *ctx)
 generate a signed 32-bit random integer.
a_i32 a_rand_lcg48i_ (a_rand_lcg48 *ctx, a_u16 x[3])
 generate a signed 32-bit random integer.
a_u32 a_rand_lcg48u (a_rand_lcg48 *ctx)
 generate an unsigned 32-bit random integer.
a_u32 a_rand_lcg48u_ (a_rand_lcg48 *ctx, a_u16 x[3])
 generate an unsigned 32-bit random integer.
a_f64 a_rand_lcg48f (a_rand_lcg48 *ctx)
 generate a 64-bit floating-point random number in [0,1).
a_f64 a_rand_lcg48f_ (a_rand_lcg48 *ctx, a_u16 x[3])
 generate a 64-bit floating-point random number in [0,1).
void a_rand_lcg48_shuf (a_rand_lcg48 *ctx, void *ptr, a_size num, a_size siz)
 shuffle the elements of an array in place using the Fisher-Yates (Knuth) shuffle algorithm.

Detailed Description

Function Documentation

◆ a_rand_lcg48_init()

void a_rand_lcg48_init ( a_rand_lcg48 * ctx,
a_i64 x )

initialize with a seed value for the linear congruential generator and 48-bit integer arithmetic.

Parameters
[in,out]ctxpoints to an instance of the linear congruential generator and 48-bit integer arithmetic
[in]xis the seed value

◆ a_rand_lcg48_next()

a_u64 a_rand_lcg48_next ( a_rand_lcg48 * ctx,
a_u16 x[3] )

perform one iteration for the linear congruential generator and 48-bit integer arithmetic.

Parameters
[in,out]ctxpoints to an instance of the linear congruential generator and 48-bit integer arithmetic
[in,out]xpoints to the state array
Returns
the result before being truncated

◆ a_rand_lcg48_seed()

void a_rand_lcg48_seed ( a_rand_lcg48 * ctx,
a_u16 const x[3] )

initialize with a specific state for the linear congruential generator and 48-bit integer arithmetic.

Parameters
[in,out]ctxpoints to an instance of the linear congruential generator and 48-bit integer arithmetic
[in]xis the specific state. If null, use the internal state.

◆ a_rand_lcg48_shuf()

void a_rand_lcg48_shuf ( a_rand_lcg48 * ctx,
void * ptr,
a_size num,
a_size siz )

shuffle the elements of an array in place using the Fisher-Yates (Knuth) shuffle algorithm.

Parameters
[in,out]ctxpoints to an instance of the linear congruential generator and 48-bit integer arithmetic
[in]ptrpoints to the elements in the array
[in]numnumber of the elements in the array
[in]sizsize of each element in the array

◆ a_rand_lcg48f()

a_f64 a_rand_lcg48f ( a_rand_lcg48 * ctx)

generate a 64-bit floating-point random number in [0,1).

Parameters
[in,out]ctxpoints to an instance of the linear congruential generator and 48-bit integer arithmetic
Returns
a 64-bit floating-point random number in [0,1)

◆ a_rand_lcg48f_()

a_f64 a_rand_lcg48f_ ( a_rand_lcg48 * ctx,
a_u16 x[3] )

generate a 64-bit floating-point random number in [0,1).

Parameters
[in,out]ctxpoints to an instance of the linear congruential generator and 48-bit integer arithmetic
[in,out]xpoints to the state array. If null, use the internal state.
Returns
a 64-bit floating-point random number in [0,1)

◆ a_rand_lcg48i()

a_i32 a_rand_lcg48i ( a_rand_lcg48 * ctx)

generate a signed 32-bit random integer.

Parameters
[in,out]ctxpoints to an instance of the linear congruential generator and 48-bit integer arithmetic
Returns
a signed 32-bit random integer

◆ a_rand_lcg48i_()

a_i32 a_rand_lcg48i_ ( a_rand_lcg48 * ctx,
a_u16 x[3] )

generate a signed 32-bit random integer.

Parameters
[in,out]ctxpoints to an instance of the linear congruential generator and 48-bit integer arithmetic
[in,out]xpoints to the state array
Returns
a signed 32-bit random integer

◆ a_rand_lcg48u()

a_u32 a_rand_lcg48u ( a_rand_lcg48 * ctx)

generate an unsigned 32-bit random integer.

Parameters
[in,out]ctxpoints to an instance of the linear congruential generator and 48-bit integer arithmetic
Returns
an unsigned 32-bit random integer

◆ a_rand_lcg48u_()

a_u32 a_rand_lcg48u_ ( a_rand_lcg48 * ctx,
a_u16 x[3] )

generate an unsigned 32-bit random integer.

Parameters
[in,out]ctxpoints to an instance of the linear congruential generator and 48-bit integer arithmetic
[in,out]xpoints to the state array. If null, use the internal state.
Returns
an unsigned 32-bit random integer