Random Number Tables
[Random Numbers]

Collaboration diagram for Random Number Tables:


Files

file  rand.c
 These are our tables of random numbers.

Defines

#define BN_RAND_TABSIZE   4096
#define BN_RAND_TABMASK   0xfff
#define BN_RANDSEED(_i, _seed)   _i = ((unsigned)_seed) % BN_RAND_TABSIZE
#define BN_RANDOM(_i)   bn_rand_table[ _i = (_i+1) % BN_RAND_TABSIZE ]
#define BN_RANDHALF(_i)   (bn_rand_table[ _i = (_i+1) % BN_RAND_TABSIZE ]-0.5)
#define BN_RANDHALF_INIT(_p)   _p = bn_rand_table
#define BN_RANDHALFTABSIZE   16535
#define bn_rand_half(_p)
#define bn_rand_init(_p, _seed)
#define bn_rand0to1(_q)   (bn_rand_half(_q)+0.5)
#define BN_SINTABSIZE   2048
#define bn_tab_sin(_a)

Functions

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.

Variables

const float bn_rand_table [BN_RAND_TABSIZE]
int bn_randhalftabsize
float bn_rand_halftab [BN_RANDHALFTABSIZE]
double bn_sin_scale
 SINTABSIZE / TWOPI.
const float bn_sin_table [BN_SINTABSIZE]
 table of sine values.
const float bn_rand_table [BN_RAND_TABSIZE]
double bn_sin_scale = 325.949323452232
 SINTABSIZE / TWOPI.
const float bn_sin_table [BN_SINTABSIZE]
 table of sine values.
int bn_randhalftabsize = BN_RANDHALFTABSIZE
float bn_rand_halftab [BN_RANDHALFTABSIZE]
float bn_rand_poison_ []

Define Documentation

#define BN_RAND_TABSIZE   4096
 

Definition at line 1018 of file bn.h.

Referenced by bn_noise_init().

#define BN_RAND_TABMASK   0xfff
 

Definition at line 1019 of file bn.h.

#define BN_RANDSEED _i,
_seed   )     _i = ((unsigned)_seed) % BN_RAND_TABSIZE
 

Definition at line 1020 of file bn.h.

Referenced by bn_noise_init().

#define BN_RANDOM _i   )     bn_rand_table[ _i = (_i+1) % BN_RAND_TABSIZE ]
 

BN_RANDOM always gives numbers between 0.0 and 1.0

Definition at line 1024 of file bn.h.

Referenced by bn_cmd_random(), and bn_noise_init().

#define BN_RANDHALF _i   )     (bn_rand_table[ _i = (_i+1) % BN_RAND_TABSIZE ]-0.5)
 

BN_RANDHALF always gives numbers between -0.5 and 0.5

Definition at line 1027 of file bn.h.

#define BN_RANDHALF_INIT _p   )     _p = bn_rand_table
 

Definition at line 1028 of file bn.h.

#define BN_RANDHALFTABSIZE   16535
 

Definition at line 1038 of file bn.h.

#define bn_rand_half _p   ) 
 

Value:

( (++(_p) >= &bn_rand_halftab[bn_randhalftabsize] || \
             (_p) < bn_rand_halftab) ? \
                *((_p) = bn_rand_halftab) : *(_p))

Definition at line 1042 of file bn.h.

#define bn_rand_init _p,
_seed   ) 
 

Value:

(_p) = &bn_rand_halftab[ \
                (int)( \
                      (bn_rand_halftab[(_seed)%bn_randhalftabsize] + 0.5) * \
                      (bn_randhalftabsize-1)) ]

Definition at line 1047 of file bn.h.

#define bn_rand0to1 _q   )     (bn_rand_half(_q)+0.5)
 

random numbers 0..1 except when benchmarking, when this is always 0.5

Definition at line 1054 of file bn.h.

#define BN_SINTABSIZE   2048
 

Definition at line 1056 of file bn.h.

#define bn_tab_sin _a   ) 
 

Value:

(((_a) > 0) ? \
        ( bn_sin_table[(int)((0.5+ (_a)*bn_sin_scale))&(BN_SINTABSIZE-1)] ) :\
        (-bn_sin_table[(int)((0.5- (_a)*bn_sin_scale))&(BN_SINTABSIZE-1)] ))

Definition at line 1058 of file bn.h.


Function Documentation

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.

M A T H T A B _ C O N S T A N T

Definition at line 3646 of file rand.c.

References bn_rand_halftab.


Variable Documentation

const float bn_rand_table[BN_RAND_TABSIZE]
 

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. Macros for accessing are in "bn.h"

Definition at line 44 of file rand.c.

int bn_randhalftabsize
 

Definition at line 1254 of file rand.c.

float bn_rand_halftab[BN_RANDHALFTABSIZE]
 

The actual table of random numbers, range -0.5 to +0.5

For benchmarking purposes, this table is zeroed.

Definition at line 1261 of file rand.c.

Referenced by bn_mathtab_constant().

double bn_sin_scale
 

SINTABSIZE / TWOPI.

Definition at line 732 of file rand.c.

const float bn_sin_table[BN_SINTABSIZE]
 

table of sine values.

from rt/mathtab.c

Definition at line 739 of file rand.c.

const float bn_rand_table[BN_RAND_TABSIZE]
 

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. Macros for accessing are in "bn.h"

Definition at line 44 of file rand.c.

double bn_sin_scale = 325.949323452232
 

SINTABSIZE / TWOPI.

Definition at line 732 of file rand.c.

const float bn_sin_table[BN_SINTABSIZE]
 

table of sine values.

from rt/mathtab.c

Definition at line 739 of file rand.c.

int bn_randhalftabsize = BN_RANDHALFTABSIZE
 

Definition at line 1254 of file rand.c.

float bn_rand_halftab[BN_RANDHALFTABSIZE]
 

The actual table of random numbers, range -0.5 to +0.5

For benchmarking purposes, this table is zeroed.

Definition at line 1261 of file rand.c.

Referenced by bn_mathtab_constant().

float bn_rand_poison_[]
 

Initial value:

 {
        9e20f, 9e20f, 9e20f, 9e20f, 9e20f, 9e20f, 9e20f, 9e20f, 9e20f, 9e20f,
        9e20f, 9e20f, 9e20f, 9e20f, 9e20f, 9e20f, 9e20f, 9e20f, 9e20f, 9e20f,
        9e20f, 9e20f, 9e20f, 9e20f, 9e20f, 9e20f, 9e20f, 9e20f, 9e20f, 9e20f,
        9e20f, 9e20f, 9e20f, 9e20f, 9e20f, 9e20f, 9e20f, 9e20f, 9e20f, 9e20f
}
Immediately after the random number table, some "poison" floating point numbers, intended to cause noticable difficulties if these are used.

Definition at line 3632 of file rand.c.


Generated on Mon Sep 18 01:25:24 2006 for BRL-CAD by  doxygen 1.4.6