#include <cmath>
#include <cstdio>
#include <algorithm>
#include "oct-time.h"
#include "randmtzig.h"
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 (const uint32_t *init_key, const int key_length) |
void | oct_init_by_entropy (void) |
void | oct_init_by_int (const uint32_t s) |
double | oct_rande (void) |
double | oct_randn (void) |
double | oct_randu (void) |
void | oct_set_state (const 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] |
#define EMANTISSA 9007199254740992.0 /* 53 bit mantissa */ |
Definition at line 656 of file randmtzig.cc.
Referenced by create_ziggurat_float_tables(), and create_ziggurat_tables().
#define EMANTISSA 4294967296.0 /* 32 bit mantissa */ |
Definition at line 656 of file randmtzig.cc.
Definition at line 657 of file randmtzig.cc.
Referenced by oct_float_rande(), and oct_rande().
Definition at line 657 of file randmtzig.cc.
#define EXP_SECTION_AREA 0.0039496598225815571993 |
Definition at line 425 of file randmtzig.cc.
Referenced by create_ziggurat_float_tables(), and create_ziggurat_tables().
#define LMASK 0x7fffffffUL /* least significant r bits */ |
Definition at line 178 of file randmtzig.cc.
Referenced by oct_float_randn().
#define MATRIX_A 0x9908b0dfUL /* constant vector a */ |
Definition at line 176 of file randmtzig.cc.
Definition at line 179 of file randmtzig.cc.
#define MT_M 397 |
Definition at line 175 of file randmtzig.cc.
Referenced by next_state().
#define NMANTISSA EMANTISSA |
Definition at line 658 of file randmtzig.cc.
Referenced by create_ziggurat_float_tables(), and create_ziggurat_tables().
#define NMANTISSA 2147483648.0 /* 31 bit mantissa */ |
Definition at line 658 of file randmtzig.cc.
#define NOR_SECTION_AREA 0.00492867323399 |
Definition at line 421 of file randmtzig.cc.
Referenced by create_ziggurat_float_tables(), and create_ziggurat_tables().
Definition at line 659 of file randmtzig.cc.
Referenced by oct_randn().
Definition at line 659 of file randmtzig.cc.
#define randi32 randmt |
Definition at line 350 of file randmtzig.cc.
Referenced by oct_float_randn(), oct_randn(), randi53(), randi54(), randu32(), and randu53().
#define RANDU randu53() |
Definition at line 660 of file randmtzig.cc.
Referenced by oct_float_rande(), oct_float_randn(), oct_rande(), and oct_randn().
#define RANDU randu32() |
Definition at line 660 of file randmtzig.cc.
Definition at line 180 of file randmtzig.cc.
Referenced by next_state().
#define UMASK 0x80000000UL /* most significant w-r bits */ |
Definition at line 177 of file randmtzig.cc.
Referenced by oct_randn().
#define USE_X86_32 0 |
Definition at line 169 of file randmtzig.cc.
#define ZIGGURAT_EXP_INV_R 0.129918765548341586 |
Definition at line 424 of file randmtzig.cc.
#define ZIGGURAT_EXP_R 7.69711747013104972 |
Definition at line 423 of file randmtzig.cc.
Referenced by create_ziggurat_float_tables(), create_ziggurat_tables(), oct_float_rande(), and oct_rande().
#define ZIGGURAT_NOR_INV_R 0.27366123732975828 |
Definition at line 420 of file randmtzig.cc.
Referenced by oct_float_randn(), and oct_randn().
#define ZIGGURAT_NOR_R 3.6541528853610088 |
Definition at line 419 of file randmtzig.cc.
Referenced by create_ziggurat_float_tables(), create_ziggurat_tables(), oct_float_randn(), and oct_randn().
#define ZIGGURAT_TABLE_SIZE 256 |
Definition at line 417 of file randmtzig.cc.
#define ZIGINT uint64_t |
Definition at line 655 of file randmtzig.cc.
Referenced by create_ziggurat_float_tables(), create_ziggurat_tables(), oct_float_rande(), and oct_rande().
#define ZIGINT uint32_t |
Definition at line 655 of file randmtzig.cc.
|
static |
Definition at line 668 of file randmtzig.cc.
References EMANTISSA, EXP_SECTION_AREA, ffe, ffi, fke, fki, fwe, fwi, i, inittf, log(), NMANTISSA, NOR_SECTION_AREA, x, ZIGGURAT_EXP_R, ZIGGURAT_NOR_R, and ZIGINT.
Referenced by oct_float_rande(), and oct_float_randn().
|
static |
Definition at line 478 of file randmtzig.cc.
References EMANTISSA, EXP_SECTION_AREA, fe, fi, i, initt, 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 oct_fill_float_rande | ( | octave_idx_type | n, |
float * | p | ||
) |
Definition at line 846 of file randmtzig.cc.
References oct_float_rande(), and p.
Referenced by octave_rand::fill().
void oct_fill_float_randn | ( | octave_idx_type | n, |
float * | p | ||
) |
Definition at line 840 of file randmtzig.cc.
References oct_float_randn(), and p.
Referenced by octave_rand::fill().
void oct_fill_float_randu | ( | octave_idx_type | n, |
float * | p | ||
) |
Definition at line 834 of file randmtzig.cc.
References oct_float_randu(), and p.
Referenced by octave_rand::fill().
void oct_fill_rande | ( | octave_idx_type | n, |
double * | p | ||
) |
Definition at line 828 of file randmtzig.cc.
References oct_rande(), and p.
Referenced by octave_rand::fill().
void oct_fill_randn | ( | octave_idx_type | n, |
double * | p | ||
) |
Definition at line 822 of file randmtzig.cc.
References oct_randn(), and p.
Referenced by octave_rand::fill().
void oct_fill_randu | ( | octave_idx_type | n, |
double * | p | ||
) |
Definition at line 816 of file randmtzig.cc.
References oct_randu(), and p.
Referenced by octave_rand::fill().
float oct_float_rande | ( | void | ) |
Definition at line 788 of file randmtzig.cc.
References create_ziggurat_float_tables(), ERANDI, ffe, fke, fwe, inittf, log(), RANDU, x, ZIGGURAT_EXP_R, and ZIGINT.
Referenced by octave_rand::do_float_scalar(), and oct_fill_float_rande().
float oct_float_randn | ( | void | ) |
Definition at line 747 of file randmtzig.cc.
References create_ziggurat_float_tables(), ffi, fki, fwi, inittf, LMASK, log(), randi32, RANDU, x, ZIGGURAT_NOR_INV_R, and ZIGGURAT_NOR_R.
Referenced by octave_rand::do_float_scalar(), and oct_fill_float_randn().
float oct_float_randu | ( | void | ) |
Definition at line 410 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 299 of file randmtzig.cc.
References left, MT_N, and state.
Referenced by octave_rand::get_internal_state().
void oct_init_by_array | ( | const uint32_t * | init_key, |
const int | key_length | ||
) |
Definition at line 212 of file randmtzig.cc.
References i, initf, k, left, 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 | ) |
Definition at line 253 of file randmtzig.cc.
References fclose, MT_N, now, oct_init_by_array(), octave::sys::time::unix_time(), and octave::sys::time::usec().
Referenced by octave_rand::do_reset(), octave_rand::initialize_mersenne_twister(), and next_state().
void oct_init_by_int | ( | const uint32_t | s | ) |
Definition at line 191 of file randmtzig.cc.
References initf, left, MT_N, s, and state.
Referenced by oct_init_by_array().
double oct_rande | ( | void | ) |
Definition at line 622 of file randmtzig.cc.
References create_ziggurat_tables(), ERANDI, fe, initt, ke, log(), RANDU, we, x, ZIGGURAT_EXP_R, and ZIGINT.
Referenced by octave_rand::do_scalar(), and oct_fill_rande().
double oct_randn | ( | void | ) |
Definition at line 557 of file randmtzig.cc.
References create_ziggurat_tables(), fi, initt, ki, log(), NRANDI, p, randi32, RANDU, UMASK, wi, x, ZIGGURAT_NOR_INV_R, and ZIGGURAT_NOR_R.
Referenced by octave_rand::do_scalar(), and oct_fill_randn().
double oct_randu | ( | void | ) |
Definition at line 403 of file randmtzig.cc.
References randu53().
Referenced by octave_rand::do_scalar(), and oct_fill_randu().
void oct_set_state | ( | const uint32_t * | save | ) |
Definition at line 291 of file randmtzig.cc.
References left, MT_N, next, and state.
Referenced by octave_rand::set_internal_state().
|
static |
Definition at line 353 of file randmtzig.cc.
|
static |
Definition at line 369 of file randmtzig.cc.
|
static |
Definition at line 332 of file randmtzig.cc.
References left, next, next_state(), and y.
|
static |
|
static |
Definition at line 394 of file randmtzig.cc.
Referenced by oct_randu().
|
static |
Definition at line 437 of file randmtzig.cc.
Referenced by create_ziggurat_tables(), and oct_rande().
|
static |
Definition at line 665 of file randmtzig.cc.
Referenced by create_ziggurat_float_tables(), and oct_float_rande().
|
static |
Definition at line 663 of file randmtzig.cc.
Referenced by create_ziggurat_float_tables(), and oct_float_randn().
|
static |
Definition at line 435 of file randmtzig.cc.
Referenced by octave::load_path::package_info::add_to_fcn_map(), octave::load_path::package_info::add_to_method_map(), create_ziggurat_tables(), octave::load_path::package_info::find_fcn(), octave::load_path::package_info::find_method(), higham_subp(), oct_randn(), octave::load_path::file_info::operator=(), and octave::documentation::~documentation().
|
static |
Definition at line 664 of file randmtzig.cc.
Referenced by create_ziggurat_float_tables(), and oct_float_rande().
|
static |
Definition at line 662 of file randmtzig.cc.
Referenced by create_ziggurat_float_tables(), and oct_float_randn().
|
static |
Definition at line 665 of file randmtzig.cc.
Referenced by create_ziggurat_float_tables(), and oct_float_rande().
|
static |
Definition at line 663 of file randmtzig.cc.
Referenced by create_ziggurat_float_tables(), and oct_float_randn().
|
static |
Definition at line 185 of file randmtzig.cc.
Referenced by next_state(), oct_init_by_array(), and oct_init_by_int().
|
static |
Definition at line 186 of file randmtzig.cc.
Referenced by create_ziggurat_tables(), oct_rande(), and oct_randn().
|
static |
Definition at line 187 of file randmtzig.cc.
Referenced by create_ziggurat_float_tables(), oct_float_rande(), and oct_float_randn().
|
static |
Definition at line 436 of file randmtzig.cc.
Referenced by create_ziggurat_tables(), and oct_rande().
|
static |
Definition at line 434 of file randmtzig.cc.
Referenced by create_ziggurat_tables(), and oct_randn().
|
static |
Definition at line 184 of file randmtzig.cc.
Referenced by symbol_info_list::symbol_info::display_line(), octave_diag_matrix::do_index_op(), octave_perm_matrix::do_index_op(), do_load(), octave::do_printf_string(), TerminalView::extendSelection(), Fcolloc(), idx_vector::is_permutation(), octave::find_file_less_than::lessThan(), octave::stream_list::list_open_files(), next_state(), oct_get_state(), oct_init_by_array(), oct_init_by_int(), oct_set_state(), octave::find_file_less_than::operator()(), pr_scale_header(), print_descriptor(), randmt(), and Screen::writeSelectionToStream().
|
static |
Definition at line 182 of file randmtzig.cc.
Referenced by KeyboardTranslator::findEntry(), TerminalView::focusNextPrevChild(), octave::jit_infer::infer(), octave_sort< T >::issorted(), next_state(), oct_set_state(), randmt(), and octave::textscan::read_until().
|
static |
Definition at line 183 of file randmtzig.cc.
Referenced by TerminalModel::activityStateSet(), QtHandles::Canvas::canvasToggleGrid(), check_state(), ddaspk_f(), ddaspk_j(), ddasrt_f(), ddasrt_g(), ddasrt_j(), ddassl_f(), ddassl_j(), Fdaspk(), Fdasrt(), Fdassl(), octave::history_dock_widget::filter_activate(), octave::workspace_view::filter_activate(), KeyboardTranslator::findEntry(), Flsode(), generate_completion(), octave::enter_shortcut::handle_direct_shortcut(), octave::file_editor_tab::handle_margin_clicked(), octave::welcome_wizard::handle_web_connect_option(), initialize_warning_options(), KeyboardTranslator::Entry::insertState(), KeyboardTranslator::Entry::matches(), next_state(), oct_get_state(), oct_init_by_array(), oct_init_by_int(), oct_set_state(), base_graphics_object::remove_all_listeners(), axes::reset_default_properties(), octave::textscan::scan(), octave::textscan::scan_complex(), KeyboardTranslator::Entry::setState(), octave::textscan::skip_whitespace(), toggle_warn(), warning_enabled(), and xreset_default_properties().
|
static |
Definition at line 437 of file randmtzig.cc.
Referenced by create_ziggurat_tables(), and oct_rande().
|
static |
Definition at line 435 of file randmtzig.cc.
Referenced by create_ziggurat_tables(), Faddeeva_w(), schur< T >::init(), EIG::init(), FloatEIG::init(), oct_randn(), and octave::math::zbesy().