GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Macros | Functions | Variables
randmtzig.cc File Reference
#include <cstdio>
#include "lo-math.h"
#include "oct-time.h"
#include "randmtzig.h"
Include dependency graph for randmtzig.cc:

Go to the source code of this file.

Macros

#define EMANTISSA   9007199254740992.0 /* 53 bit mantissa */
 
#define EMANTISSA   4294967296.0 /* 32 bit mantissa */
 
#define ERANDI   randi53() /* 53 bits for mantissa */
 
#define ERANDI   randi32() /* 32 bits for mantissa */
 
#define EXP_SECTION_AREA   0.0039496598225815571993
 
#define LMASK   0x7fffffffUL /* least significant r bits */
 
#define MATRIX_A   0x9908b0dfUL /* constant vector a */
 
#define MIXBITS(u, v)   ( ((u) & UMASK) | ((v) & LMASK) )
 
#define MT_M   397
 
#define NMANTISSA   EMANTISSA
 
#define NMANTISSA   2147483648.0 /* 31 bit mantissa */
 
#define NOR_SECTION_AREA   0.00492867323399
 
#define NRANDI   randi54() /* 53 bits for mantissa + 1 bit sign */
 
#define NRANDI   randi32() /* 31 bits for mantissa + 1 bit sign */
 
#define randi32   randmt
 
#define RANDU   randu53()
 
#define RANDU   randu32()
 
#define TWIST(u, v)   ((MIXBITS(u,v) >> 1) ^ ((v)&1UL ? MATRIX_A : 0UL))
 
#define UMASK   0x80000000UL /* most significant w-r bits */
 
#define USE_X86_32   0
 
#define ZIGGURAT_EXP_INV_R   0.129918765548341586
 
#define ZIGGURAT_EXP_R   7.69711747013104972
 
#define ZIGGURAT_NOR_INV_R   0.27366123732975828
 
#define ZIGGURAT_NOR_R   3.6541528853610088
 
#define ZIGGURAT_TABLE_SIZE   256
 
#define ZIGINT   uint64_t
 
#define ZIGINT   uint32_t
 

Functions

static void create_ziggurat_float_tables (void)
 
static void create_ziggurat_tables (void)
 
static void next_state (void)
 
void oct_fill_float_rande (octave_idx_type n, float *p)
 
void oct_fill_float_randn (octave_idx_type n, float *p)
 
void oct_fill_float_randu (octave_idx_type n, float *p)
 
void oct_fill_rande (octave_idx_type n, double *p)
 
void oct_fill_randn (octave_idx_type n, double *p)
 
void oct_fill_randu (octave_idx_type n, double *p)
 
float oct_float_rande (void)
 
float oct_float_randn (void)
 
float oct_float_randu (void)
 
void oct_get_state (uint32_t *save)
 
void oct_init_by_array (uint32_t *init_key, int key_length)
 
void oct_init_by_entropy (void)
 
void oct_init_by_int (uint32_t s)
 
double oct_rande (void)
 
double oct_randn (void)
 
double oct_randu (void)
 
void oct_set_state (uint32_t *save)
 
static uint64_t randi53 (void)
 
static uint64_t randi54 (void)
 
static uint32_t randmt (void)
 
static float randu32 (void)
 
static double randu53 (void)
 

Variables

static double fe [256]
 
static float ffe [256]
 
static float ffi [256]
 
static double fi [256]
 
static uint32_t fke [256]
 
static uint32_t fki [256]
 
static float fwe [256]
 
static float fwi [256]
 
static int initf = 0
 
static int initt = 1
 
static int inittf = 1
 
static uint64_t ke [256]
 
static uint64_t ki [256]
 
static int left = 1
 
static uint32_t * next
 
static uint32_t state [624]
 
static double we [256]
 
static double wi [256]
 

Macro Definition Documentation

#define EMANTISSA   9007199254740992.0 /* 53 bit mantissa */

Definition at line 661 of file randmtzig.cc.

Referenced by create_ziggurat_float_tables(), and create_ziggurat_tables().

#define EMANTISSA   4294967296.0 /* 32 bit mantissa */

Definition at line 661 of file randmtzig.cc.

#define ERANDI   randi53() /* 53 bits for mantissa */

Definition at line 662 of file randmtzig.cc.

Referenced by oct_float_rande(), and oct_rande().

#define ERANDI   randi32() /* 32 bits for mantissa */

Definition at line 662 of file randmtzig.cc.

#define EXP_SECTION_AREA   0.0039496598225815571993

Definition at line 430 of file randmtzig.cc.

Referenced by create_ziggurat_float_tables(), and create_ziggurat_tables().

#define LMASK   0x7fffffffUL /* least significant r bits */

Definition at line 179 of file randmtzig.cc.

Referenced by oct_float_randn().

#define MATRIX_A   0x9908b0dfUL /* constant vector a */

Definition at line 177 of file randmtzig.cc.

#define MIXBITS (   u,
 
)    ( ((u) & UMASK) | ((v) & LMASK) )

Definition at line 180 of file randmtzig.cc.

#define MT_M   397

Definition at line 176 of file randmtzig.cc.

Referenced by next_state().

#define NMANTISSA   EMANTISSA

Definition at line 663 of file randmtzig.cc.

Referenced by create_ziggurat_float_tables(), and create_ziggurat_tables().

#define NMANTISSA   2147483648.0 /* 31 bit mantissa */

Definition at line 663 of file randmtzig.cc.

#define NOR_SECTION_AREA   0.00492867323399

Definition at line 426 of file randmtzig.cc.

Referenced by create_ziggurat_float_tables(), and create_ziggurat_tables().

#define NRANDI   randi54() /* 53 bits for mantissa + 1 bit sign */

Definition at line 664 of file randmtzig.cc.

Referenced by oct_randn().

#define NRANDI   randi32() /* 31 bits for mantissa + 1 bit sign */

Definition at line 664 of file randmtzig.cc.

#define randi32   randmt

Definition at line 355 of file randmtzig.cc.

Referenced by oct_float_randn(), oct_randn(), randi53(), randi54(), randu32(), and randu53().

#define RANDU   randu53()

Definition at line 665 of file randmtzig.cc.

Referenced by oct_float_rande(), oct_float_randn(), oct_rande(), and oct_randn().

#define RANDU   randu32()

Definition at line 665 of file randmtzig.cc.

#define TWIST (   u,
 
)    ((MIXBITS(u,v) >> 1) ^ ((v)&1UL ? MATRIX_A : 0UL))

Definition at line 181 of file randmtzig.cc.

Referenced by next_state().

#define UMASK   0x80000000UL /* most significant w-r bits */

Definition at line 178 of file randmtzig.cc.

Referenced by oct_randn().

#define USE_X86_32   0

Definition at line 170 of file randmtzig.cc.

#define ZIGGURAT_EXP_INV_R   0.129918765548341586

Definition at line 429 of file randmtzig.cc.

#define ZIGGURAT_EXP_R   7.69711747013104972
#define ZIGGURAT_NOR_INV_R   0.27366123732975828

Definition at line 425 of file randmtzig.cc.

Referenced by oct_float_randn(), and oct_randn().

#define ZIGGURAT_NOR_R   3.6541528853610088
#define ZIGGURAT_TABLE_SIZE   256

Definition at line 422 of file randmtzig.cc.

#define ZIGINT   uint64_t
#define ZIGINT   uint32_t

Definition at line 660 of file randmtzig.cc.

Function Documentation

static void create_ziggurat_float_tables ( void  )
static
static void create_ziggurat_tables ( void  )
static

Definition at line 483 of file randmtzig.cc.

References EMANTISSA, EXP_SECTION_AREA, fe, fi, ke, ki, log(), NMANTISSA, NOR_SECTION_AREA, we, wi, x, ZIGGURAT_EXP_R, ZIGGURAT_NOR_R, and ZIGINT.

Referenced by oct_rande(), and oct_randn().

static void next_state ( void  )
static

Definition at line 311 of file randmtzig.cc.

References MT_M, MT_N, next, oct_init_by_entropy(), p, state, and TWIST.

Referenced by randmt().

void oct_fill_float_rande ( octave_idx_type  n,
float *  p 
)

Definition at line 861 of file randmtzig.cc.

References oct_float_rande().

Referenced by octave_rand::fill().

void oct_fill_float_randn ( octave_idx_type  n,
float *  p 
)

Definition at line 853 of file randmtzig.cc.

References oct_float_randn().

Referenced by octave_rand::fill().

void oct_fill_float_randu ( octave_idx_type  n,
float *  p 
)

Definition at line 845 of file randmtzig.cc.

References oct_float_randu().

Referenced by octave_rand::fill().

void oct_fill_rande ( octave_idx_type  n,
double p 
)

Definition at line 837 of file randmtzig.cc.

References oct_rande().

Referenced by octave_rand::fill().

void oct_fill_randn ( octave_idx_type  n,
double p 
)

Definition at line 829 of file randmtzig.cc.

References oct_randn().

Referenced by octave_rand::fill().

void oct_fill_randu ( octave_idx_type  n,
double p 
)

Definition at line 821 of file randmtzig.cc.

References oct_randu().

Referenced by octave_rand::fill().

float oct_float_rande ( void  )
float oct_float_randn ( void  )
float oct_float_randu ( void  )

Definition at line 415 of file randmtzig.cc.

References randu32().

Referenced by octave_rand::do_float_scalar(), and oct_fill_float_randu().

void oct_get_state ( uint32_t *  save)

Definition at line 302 of file randmtzig.cc.

References left, MT_N, and state.

Referenced by octave_rand::get_internal_state().

void oct_init_by_array ( uint32_t *  init_key,
int  key_length 
)

Definition at line 213 of file randmtzig.cc.

References k, MT_N, oct_init_by_int(), and state.

Referenced by oct_init_by_entropy(), and octave_rand::set_internal_state().

void oct_init_by_entropy ( void  )
void oct_init_by_int ( uint32_t  s)

Definition at line 192 of file randmtzig.cc.

References MT_N, and state.

Referenced by oct_init_by_array().

double oct_rande ( void  )

Definition at line 627 of file randmtzig.cc.

References create_ziggurat_tables(), ERANDI, fe, ke, log(), RANDU, we, x, ZIGGURAT_EXP_R, and ZIGINT.

Referenced by octave_rand::do_scalar(), and oct_fill_rande().

double oct_randn ( void  )
double oct_randu ( void  )

Definition at line 408 of file randmtzig.cc.

References randu53().

Referenced by octave_rand::do_scalar(), and oct_fill_randu().

void oct_set_state ( uint32_t *  save)

Definition at line 292 of file randmtzig.cc.

References MT_N, next, and state.

Referenced by octave_rand::set_internal_state().

static uint64_t randi53 ( void  )
static

Definition at line 358 of file randmtzig.cc.

References p, randi32, and u.

static uint64_t randi54 ( void  )
static

Definition at line 374 of file randmtzig.cc.

References p, randi32, and u.

static uint32_t randmt ( void  )
static

Definition at line 337 of file randmtzig.cc.

References next, next_state(), and y.

static float randu32 ( void  )
static

Definition at line 391 of file randmtzig.cc.

References randi32.

Referenced by oct_float_randu().

static double randu53 ( void  )
static

Definition at line 399 of file randmtzig.cc.

References a, b, and randi32.

Referenced by oct_randu().

Variable Documentation

double fe[256]
static

Definition at line 442 of file randmtzig.cc.

Referenced by create_ziggurat_tables(), and oct_rande().

float ffe[256]
static

Definition at line 670 of file randmtzig.cc.

Referenced by create_ziggurat_float_tables(), and oct_float_rande().

float ffi[256]
static

Definition at line 668 of file randmtzig.cc.

Referenced by create_ziggurat_float_tables(), and oct_float_randn().

double fi[256]
static
uint32_t fke[256]
static

Definition at line 669 of file randmtzig.cc.

Referenced by create_ziggurat_float_tables(), and oct_float_rande().

uint32_t fki[256]
static

Definition at line 667 of file randmtzig.cc.

Referenced by create_ziggurat_float_tables(), and oct_float_randn().

float fwe[256]
static

Definition at line 670 of file randmtzig.cc.

Referenced by create_ziggurat_float_tables(), and oct_float_rande().

float fwi[256]
static

Definition at line 668 of file randmtzig.cc.

Referenced by create_ziggurat_float_tables(), and oct_float_randn().

int initf = 0
static

Definition at line 186 of file randmtzig.cc.

int initt = 1
static

Definition at line 187 of file randmtzig.cc.

int inittf = 1
static

Definition at line 188 of file randmtzig.cc.

uint64_t ke[256]
static

Definition at line 441 of file randmtzig.cc.

Referenced by create_ziggurat_tables(), and oct_rande().

uint64_t ki[256]
static

Definition at line 439 of file randmtzig.cc.

Referenced by create_ziggurat_tables(), and oct_randn().

int left = 1
static
uint32_t* next
static
uint32_t state[624]
static
double we[256]
static

Definition at line 442 of file randmtzig.cc.

Referenced by create_ziggurat_tables(), and oct_rande().

double wi[256]
static