Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
ran_array.h File Reference

Knuth's random number generator, from his rng.c (The Art of Computer Programming, Volume 2, Section 3.6), which ran_array.c compiles into Aleph. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ALEPH_RAN_ARRAY_DEPRECATED    [[deprecated("ran_array.h goes in 8.0.0; use the engines of <random> instead")]]
 
#define ran_arr_next()   (*ran_arr_ptr >=0 ? *ran_arr_ptr++ : ran_arr_cycle())
 The next random number.
 

Functions

void ran_start (long seed)
 Starts the generator with seed: do this before using it.
 
long ran_arr_cycle (void)
 Makes a new batch of numbers and returns its first one: ran_arr_next() calls it when the batch runs out.
 

Variables

long * ran_arr_ptr
 Points to the next number of the batch, or to -1 when the batch has run out.
 

Detailed Description

Knuth's random number generator, from his rng.c (The Art of Computer Programming, Volume 2, Section 3.6), which ran_array.c compiles into Aleph.

After ran_start(seed), ran_arr_next() gives the numbers, in [0, 2^30).

Deprecated:
Nothing of Aleph uses it: ran_array.h and ran_array.c go in 8.0.0. Use the engines of <random> instead.

Definition in file ran_array.h.

Macro Definition Documentation

◆ ALEPH_RAN_ARRAY_DEPRECATED

#define ALEPH_RAN_ARRAY_DEPRECATED    [[deprecated("ran_array.h goes in 8.0.0; use the engines of <random> instead")]]

Definition at line 68 of file ran_array.h.

◆ ran_arr_next

#define ran_arr_next ( )    (*ran_arr_ptr >=0 ? *ran_arr_ptr++ : ran_arr_cycle())

The next random number.

Deprecated:
ran_array.h goes in 8.0.0.

Definition at line 99 of file ran_array.h.

Function Documentation

◆ ran_arr_cycle()

long ran_arr_cycle ( void  )
extern

Makes a new batch of numbers and returns its first one: ran_arr_next() calls it when the batch runs out.

Without ran_start(), it first starts the generator as ran_start(314159).

Deprecated:
ran_array.h goes in 8.0.0.

Definition at line 97 of file ran_array.c.

References QUALITY, ran_arr_buf, ran_arr_dummy, ran_arr_ptr, ran_array(), and ran_start().

◆ ran_start()

void ran_start ( long  seed)
extern

Starts the generator with seed: do this before using it.

Deprecated:
ran_array.h goes in 8.0.0.

Definition at line 66 of file ran_array.c.

References is_odd, KK, LL, MM, mod_diff, ran_arr_ptr, ran_arr_started, ran_array(), ran_x, seed, and TT.

Referenced by ran_arr_cycle(), TEST(), and TEST().

Variable Documentation

◆ ran_arr_ptr

long* ran_arr_ptr
extern

Points to the next number of the batch, or to -1 when the batch has run out.

Deprecated:
ran_array.h goes in 8.0.0.

Definition at line 58 of file ran_array.c.

Referenced by ran_arr_cycle(), and ran_start().