GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
randmtzig.cc File Reference
#include <cmath>
#include <cstdio>
#include <algorithm>
#include "oct-time.h"
#include "randmtzig.h"
Include dependency graph for randmtzig.cc:

Go to the source code of this file.

Namespaces

 octave
 

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   randu24()
 
#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 octave::create_ziggurat_float_tables (void)
 
void octave::create_ziggurat_tables (void)
 
void octave::get_mersenne_twister_state (uint32_t *save)
 
void octave::init_mersenne_twister (const uint32_t *init_key, const int key_length)
 
void octave::init_mersenne_twister (const uint32_t s)
 
void octave::init_mersenne_twister (void)
 
static void octave::next_state (void)
 
template<>
void octave::rand_exponential (octave_idx_type n, double *p)
 
template<>
void octave::rand_exponential (octave_idx_type n, float *p)
 
template<>
double octave::rand_exponential< double > (void)
 
template<>
float octave::rand_exponential< float > (void)
 
template<>
void octave::rand_normal (octave_idx_type n, double *p)
 
template<>
void octave::rand_normal (octave_idx_type n, float *p)
 
template<>
double octave::rand_normal< double > (void)
 
template<>
float octave::rand_normal< float > (void)
 
template<>
void octave::rand_uniform (octave_idx_type n, float *p)
 
template<>
void octave::rand_uniform< double > (octave_idx_type n, double *p)
 
template<>
double octave::rand_uniform< double > (void)
 
template<>
float octave::rand_uniform< float > (void)
 
static uint64_t octave::randi53 (void)
 
static uint64_t octave::randi54 (void)
 
static uint32_t octave::randmt (void)
 
static float octave::randu24 (void)
 
static double octave::randu53 (void)
 
void octave::set_mersenne_twister_state (const uint32_t *save)
 

Variables

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

Macro Definition Documentation

◆ EMANTISSA [1/2]

#define EMANTISSA   9007199254740992.0 /* 53 bit mantissa */

Definition at line 681 of file randmtzig.cc.

◆ EMANTISSA [2/2]

#define EMANTISSA   4294967296.0 /* 32 bit mantissa */

Definition at line 681 of file randmtzig.cc.

◆ ERANDI [1/2]

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

Definition at line 682 of file randmtzig.cc.

◆ ERANDI [2/2]

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

Definition at line 682 of file randmtzig.cc.

◆ EXP_SECTION_AREA

#define EXP_SECTION_AREA   0.0039496598225815571993

Definition at line 437 of file randmtzig.cc.

◆ LMASK

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

Definition at line 185 of file randmtzig.cc.

◆ MATRIX_A

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

Definition at line 183 of file randmtzig.cc.

◆ MIXBITS

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

Definition at line 186 of file randmtzig.cc.

◆ MT_M

#define MT_M   397

Definition at line 182 of file randmtzig.cc.

◆ NMANTISSA [1/2]

#define NMANTISSA   EMANTISSA

Definition at line 683 of file randmtzig.cc.

◆ NMANTISSA [2/2]

#define NMANTISSA   2147483648.0 /* 31 bit mantissa */

Definition at line 683 of file randmtzig.cc.

◆ NOR_SECTION_AREA

#define NOR_SECTION_AREA   0.00492867323399

Definition at line 433 of file randmtzig.cc.

◆ NRANDI [1/2]

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

Definition at line 684 of file randmtzig.cc.

◆ NRANDI [2/2]

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

Definition at line 684 of file randmtzig.cc.

◆ randi32

#define randi32   randmt

Definition at line 350 of file randmtzig.cc.

◆ RANDU [1/2]

#define RANDU   randu53()

Definition at line 685 of file randmtzig.cc.

◆ RANDU [2/2]

#define RANDU   randu24()

Definition at line 685 of file randmtzig.cc.

◆ TWIST

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

Definition at line 187 of file randmtzig.cc.

◆ UMASK

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

Definition at line 184 of file randmtzig.cc.

◆ USE_X86_32

#define USE_X86_32   0

Definition at line 174 of file randmtzig.cc.

◆ ZIGGURAT_EXP_INV_R

#define ZIGGURAT_EXP_INV_R   0.129918765548341586

Definition at line 436 of file randmtzig.cc.

◆ ZIGGURAT_EXP_R

#define ZIGGURAT_EXP_R   7.69711747013104972

Definition at line 435 of file randmtzig.cc.

◆ ZIGGURAT_NOR_INV_R

#define ZIGGURAT_NOR_INV_R   0.27366123732975828

Definition at line 432 of file randmtzig.cc.

◆ ZIGGURAT_NOR_R

#define ZIGGURAT_NOR_R   3.6541528853610088

Definition at line 431 of file randmtzig.cc.

◆ ZIGGURAT_TABLE_SIZE

#define ZIGGURAT_TABLE_SIZE   256

Definition at line 429 of file randmtzig.cc.

◆ ZIGINT [1/2]

#define ZIGINT   uint64_t

Definition at line 680 of file randmtzig.cc.

◆ ZIGINT [2/2]

#define ZIGINT   uint32_t

Definition at line 680 of file randmtzig.cc.