A supply of fast pseudo-random numbers from table in bn/rand.c. The values are in the open interval (i.e. exclusive) of 0.0 to 1.0 range with a period of 4096.
More...
A supply of fast pseudo-random numbers from table in bn/rand.c. The values are in the open interval (i.e. exclusive) of 0.0 to 1.0 range with a period of 4096.
- Usage:
unsigned idx;
float f;
while (NEED_MORE_RAND_NUMBERS) {
}
#define BN_RANDSEED(_i, _seed)
Note that the values from bn_rand_half() become all 0.0 when the benchmark flag is set (bn_rand_halftab is set to all 0's). The numbers from bn_rand_table do not change, because the procedural noise would cease to exist.
◆ BN_RAND_TABSIZE
#define BN_RAND_TABSIZE 4096 |
◆ BN_RAND_TABMASK
#define BN_RAND_TABMASK 0xfff |
◆ BN_RANDSEED
◆ BN_RANDOM
BN_RANDOM always gives numbers between the open interval 0.0 to 1.0
Definition at line 77 of file rand.h.
◆ BN_RANDHALF
BN_RANDHALF always gives numbers between the open interval -0.5 and 0.5
Definition at line 80 of file rand.h.
◆ BN_RANDHALF_INIT
◆ BN_RANDHALFTABSIZE
#define BN_RANDHALFTABSIZE 16535 |
Powers of two give streaking
Definition at line 83 of file rand.h.
◆ bn_rand_half
#define bn_rand_half |
( |
|
_p | ) |
|
Value:
float bn_rand_halftab[BN_RANDHALFTABSIZE]
random numbers between the closed interval -0.5 to 0.5 inclusive, except when benchmark flag is set, when this becomes a constant 0.0
- Parameters
-
Definition at line 101 of file rand.h.
◆ bn_rand_init
#define bn_rand_init |
( |
|
_p, |
|
|
|
_seed |
|
) |
| |
Value:initialize the seed for the large random number table (halftab)
- Parameters
-
Definition at line 114 of file rand.h.
◆ bn_rand0to1
random numbers in the closed interval 0.0 to 1.0 range (inclusive) except when benchmarking, when this is always 0.5
- Parameters
-
Definition at line 127 of file rand.h.
◆ BN_SINTABSIZE
#define BN_SINTABSIZE 2048 |
◆ bn_tab_sin
Value: (((_a) > 0) ? \
const float bn_sin_table[BN_SINTABSIZE]
Definition at line 131 of file rand.h.
◆ bn_mathtab_constant()
void bn_mathtab_constant |
( |
void |
| ) |
|
For benchmarking purposes, make the random number table predictable. Setting to all zeros keeps dithered values at their original values.
◆ bn_rand_sph_sample()
Generate a sample point on a sphere per Marsaglia (1972).
Note that bn_sph_sample and its internal routines do not initialize the randmt seed - the user should call bn_randmt_seed in their code if a variable seed is required.
◆ bn_rand_table
This is our table of random numbers. Rather than calling drand48() or random() or rand() we just pick numbers out of this table. This table has 4096 unique entries with floating point values ranging from the open interval (i.e. exclusive) 0.0 to 1.0 range.
There are convenience macros for access in the bn.h header.
◆ bn_randhalftabsize
◆ bn_rand_halftab
The actual table of random floating point numbers with values in the closed interval (i.e. inclusive) -0.5 to +0.5 range.
For benchmarking purposes, this table is zeroed.
◆ bn_sin_table
table of floating point sine values in the closed (i.e. inclusive) interval -1.0 to 1.0 range.