GNU Octave  3.8.0
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.c File Reference
#include <stdio.h>
#include <time.h>
#include "lo-math.h"
#include "randmtzig.h"
Include dependency graph for randmtzig.c:

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 664 of file randmtzig.c.

Referenced by create_ziggurat_float_tables(), and create_ziggurat_tables().

#define EMANTISSA   4294967296.0 /* 32 bit mantissa */

Definition at line 664 of file randmtzig.c.

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

Definition at line 665 of file randmtzig.c.

Referenced by oct_float_rande(), and oct_rande().

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

Definition at line 665 of file randmtzig.c.

#define EXP_SECTION_AREA   0.0039496598225815571993

Definition at line 433 of file randmtzig.c.

Referenced by create_ziggurat_float_tables(), and create_ziggurat_tables().

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

Definition at line 183 of file randmtzig.c.

Referenced by oct_float_randn().

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

Definition at line 181 of file randmtzig.c.

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

Definition at line 184 of file randmtzig.c.

#define MT_M   397

Definition at line 180 of file randmtzig.c.

Referenced by next_state().

#define NMANTISSA   EMANTISSA

Definition at line 666 of file randmtzig.c.

Referenced by create_ziggurat_float_tables(), and create_ziggurat_tables().

#define NMANTISSA   2147483648.0 /* 31 bit mantissa */

Definition at line 666 of file randmtzig.c.

#define NOR_SECTION_AREA   0.00492867323399

Definition at line 429 of file randmtzig.c.

Referenced by create_ziggurat_float_tables(), and create_ziggurat_tables().

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

Definition at line 667 of file randmtzig.c.

Referenced by oct_randn().

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

Definition at line 667 of file randmtzig.c.

#define randi32   randmt

Definition at line 358 of file randmtzig.c.

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

#define RANDU   randu53()

Definition at line 668 of file randmtzig.c.

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

#define RANDU   randu32()

Definition at line 668 of file randmtzig.c.

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

Definition at line 185 of file randmtzig.c.

Referenced by next_state().

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

Definition at line 182 of file randmtzig.c.

Referenced by oct_randn().

#define USE_X86_32   0

Definition at line 174 of file randmtzig.c.

#define ZIGGURAT_EXP_INV_R   0.129918765548341586

Definition at line 432 of file randmtzig.c.

#define ZIGGURAT_EXP_R   7.69711747013104972
#define ZIGGURAT_NOR_INV_R   0.27366123732975828

Definition at line 428 of file randmtzig.c.

Referenced by oct_float_randn(), and oct_randn().

#define ZIGGURAT_NOR_R   3.6541528853610088
#define ZIGGURAT_TABLE_SIZE   256

Definition at line 425 of file randmtzig.c.

#define ZIGINT   uint64_t
#define ZIGINT   uint32_t

Definition at line 663 of file randmtzig.c.

Function Documentation

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

Definition at line 486 of file randmtzig.c.

References EMANTISSA, EXP_SECTION_AREA, ke, ki, NMANTISSA, NOR_SECTION_AREA, 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 314 of file randmtzig.c.

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

Referenced by randmt().

void oct_fill_float_rande ( octave_idx_type  n,
float p 
)

Definition at line 865 of file randmtzig.c.

References oct_float_rande().

Referenced by octave_rand::fill().

void oct_fill_float_randn ( octave_idx_type  n,
float p 
)

Definition at line 857 of file randmtzig.c.

References oct_float_randn().

Referenced by octave_rand::fill().

void oct_fill_float_randu ( octave_idx_type  n,
float p 
)

Definition at line 849 of file randmtzig.c.

References oct_float_randu().

Referenced by octave_rand::fill().

void oct_fill_rande ( octave_idx_type  n,
double p 
)

Definition at line 841 of file randmtzig.c.

References oct_rande().

Referenced by octave_rand::fill().

void oct_fill_randn ( octave_idx_type  n,
double p 
)

Definition at line 833 of file randmtzig.c.

References oct_randn().

Referenced by octave_rand::fill().

void oct_fill_randu ( octave_idx_type  n,
double p 
)

Definition at line 825 of file randmtzig.c.

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 418 of file randmtzig.c.

References randu32().

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

void oct_get_state ( uint32_t *  save)

Definition at line 305 of file randmtzig.c.

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 217 of file randmtzig.c.

References 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 196 of file randmtzig.c.

References MT_N, and state.

Referenced by oct_init_by_array().

double oct_rande ( void  )

Definition at line 630 of file randmtzig.c.

References create_ziggurat_tables(), ERANDI, ke, RANDU, 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 411 of file randmtzig.c.

References randu53().

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

void oct_set_state ( uint32_t *  save)

Definition at line 295 of file randmtzig.c.

References MT_N, next, and state.

Referenced by octave_rand::set_internal_state().

static uint64_t randi53 ( void  )
static

Definition at line 361 of file randmtzig.c.

References randi32.

static uint64_t randi54 ( void  )
static

Definition at line 377 of file randmtzig.c.

References randi32.

static uint32_t randmt ( void  )
static

Definition at line 340 of file randmtzig.c.

References next, and next_state().

static float randu32 ( void  )
static

Definition at line 394 of file randmtzig.c.

References randi32.

Referenced by oct_float_randu().

static double randu53 ( void  )
static

Definition at line 402 of file randmtzig.c.

References randi32.

Referenced by oct_randu().

Variable Documentation

double fe[256]
static

Definition at line 445 of file randmtzig.c.

float ffe[256]
static

Definition at line 673 of file randmtzig.c.

float ffi[256]
static

Definition at line 671 of file randmtzig.c.

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

Definition at line 672 of file randmtzig.c.

Referenced by create_ziggurat_float_tables(), and oct_float_rande().

uint32_t fki[256]
static

Definition at line 670 of file randmtzig.c.

Referenced by create_ziggurat_float_tables(), and oct_float_randn().

float fwe[256]
static

Definition at line 673 of file randmtzig.c.

float fwi[256]
static

Definition at line 671 of file randmtzig.c.

int initf = 0
static

Definition at line 190 of file randmtzig.c.

int initt = 1
static

Definition at line 191 of file randmtzig.c.

int inittf = 1
static

Definition at line 192 of file randmtzig.c.

uint64_t ke[256]
static

Definition at line 444 of file randmtzig.c.

Referenced by create_ziggurat_tables(), and oct_rande().

uint64_t ki[256]
static

Definition at line 442 of file randmtzig.c.

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 445 of file randmtzig.c.

double wi[256]
static