#include "oct-rand.h"
Public Member Functions | |
~octave_rand (void) | |
Static Public Member Functions | |
static std::string | distribution (void) |
static void | distribution (const std::string &d) |
static void | exponential_distribution (void) |
static void | gamma_distribution (void) |
static bool | instance_ok (void) |
static Matrix | matrix (octave_idx_type r, octave_idx_type c, double a=1.0) |
static NDArray | nd_array (const dim_vector &dims, double a=1.0) |
static void | normal_distribution (void) |
static void | poisson_distribution (void) |
static void | reset (void) |
static void | reset (const std::string &d) |
static double | scalar (double a=1.0) |
static void | seed (double s) |
static double | seed (void) |
static void | state (const ColumnVector &s, const std::string &d=std::string()) |
static ColumnVector | state (const std::string &d=std::string()) |
static void | uniform_distribution (void) |
static Array< double > | vector (octave_idx_type n, double a=1.0) |
Protected Member Functions | |
octave_rand (void) | |
Private Types | |
enum | { unknown_dist, uniform_dist, normal_dist, expon_dist, poisson_dist, gamma_dist } |
Private Member Functions | |
std::string | do_distribution (void) |
void | do_distribution (const std::string &d) |
void | do_exponential_distribution (void) |
void | do_gamma_distribution (void) |
Matrix | do_matrix (octave_idx_type r, octave_idx_type c, double a=1.) |
NDArray | do_nd_array (const dim_vector &dims, double a=1.) |
void | do_normal_distribution (void) |
void | do_poisson_distribution (void) |
void | do_reset () |
void | do_reset (const std::string &d) |
double | do_scalar (double a=1.) |
void | do_seed (double s) |
double | do_seed (void) |
ColumnVector | do_state (const std::string &d) |
void | do_state (const ColumnVector &s, const std::string &d) |
void | do_uniform_distribution (void) |
Array< double > | do_vector (octave_idx_type n, double a=1.) |
void | fill (octave_idx_type len, double *v, double a) |
int | get_dist_id (const std::string &d) |
ColumnVector | get_internal_state (void) |
void | initialize_mersenne_twister (void) |
void | initialize_ranlib_generators (void) |
void | save_state (void) |
void | set_internal_state (const ColumnVector &s) |
void | switch_to_generator (int dist) |
Static Private Member Functions | |
static void | cleanup_instance (void) |
Private Attributes | |
int | current_distribution |
std::map< int, ColumnVector > | rand_states |
bool | use_old_generators |
Static Private Attributes | |
static octave_rand * | instance = 0 |
Definition at line 34 of file oct-rand.h.
anonymous enum [private] |
Definition at line 165 of file oct-rand.h.
octave_rand::octave_rand | ( | void | ) | [protected] |
Definition at line 78 of file oct-rand.cc.
References initialize_mersenne_twister(), and initialize_ranlib_generators().
Referenced by instance_ok().
octave_rand::~octave_rand | ( | void | ) | [inline] |
Definition at line 44 of file oct-rand.h.
static void octave_rand::cleanup_instance | ( | void | ) | [inline, static, private] |
Definition at line 163 of file oct-rand.h.
Referenced by instance_ok().
static std::string octave_rand::distribution | ( | void | ) | [inline, static] |
Definition at line 90 of file oct-rand.h.
Referenced by do_rand().
static void octave_rand::distribution | ( | const std::string & | d | ) | [inline, static] |
Definition at line 97 of file oct-rand.h.
std::string octave_rand::do_distribution | ( | void | ) | [private] |
Definition at line 231 of file oct-rand.cc.
References current_distribution, expon_dist, gamma_dist, normal_dist, poisson_dist, and uniform_dist.
void octave_rand::do_distribution | ( | const std::string & | d | ) | [private] |
Definition at line 267 of file oct-rand.cc.
References expon_dist, exponential_distribution(), gamma_dist, gamma_distribution(), get_dist_id(), normal_dist, normal_distribution(), poisson_dist, poisson_distribution(), uniform_dist, and uniform_distribution().
void octave_rand::do_exponential_distribution | ( | void | ) | [private] |
Definition at line 317 of file oct-rand.cc.
References expon_dist, F77_FUNC(), and switch_to_generator().
void octave_rand::do_gamma_distribution | ( | void | ) | [private] |
Definition at line 333 of file oct-rand.cc.
References F77_FUNC(), gamma_dist, and switch_to_generator().
Matrix octave_rand::do_matrix | ( | octave_idx_type | r, | |
octave_idx_type | c, | |||
double | a = 1. | |||
) | [private] |
Definition at line 423 of file oct-rand.cc.
References Array< T >::capacity(), Array< T >::clear(), current_liboctave_error_handler, fill(), and Array< T >::fortran_vec().
NDArray octave_rand::do_nd_array | ( | const dim_vector & | dims, | |
double | a = 1. | |||
) | [private] |
Definition at line 441 of file oct-rand.cc.
References dim_vector::all_zero(), Array< T >::capacity(), Array< T >::clear(), fill(), and Array< T >::fortran_vec().
void octave_rand::do_normal_distribution | ( | void | ) | [private] |
Definition at line 309 of file oct-rand.cc.
References F77_FUNC(), normal_dist, and switch_to_generator().
void octave_rand::do_poisson_distribution | ( | void | ) | [private] |
Definition at line 325 of file oct-rand.cc.
References F77_FUNC(), poisson_dist, and switch_to_generator().
void octave_rand::do_reset | ( | void | ) | [private] |
Definition at line 175 of file oct-rand.cc.
References initialize_ranlib_generators(), and use_old_generators.
void octave_rand::do_reset | ( | const std::string & | d | ) | [private] |
Definition at line 210 of file oct-rand.cc.
References current_distribution, get_dist_id(), get_internal_state(), oct_init_by_entropy(), rand_states, and use_old_generators.
Definition at line 342 of file oct-rand.cc.
References current_distribution, dgenexp(), dgengam(), dgennor(), dgenunf(), dignpoi(), expon_dist, F77_FUNC(), gamma_dist, normal_dist, oct_rande(), oct_randg(), oct_randn(), oct_randp(), oct_randu(), octave_NaN, poisson_dist, save_state(), uniform_dist, use_old_generators, xisinf(), and xisnan().
void octave_rand::do_seed | ( | double | s | ) | [private] |
Definition at line 148 of file oct-rand.cc.
References d, F77_FUNC(), oct_mach_info::flt_fmt_ieee_big_endian, force_to_fit_range(), oct_mach_info::native_float_format(), setsd(), and use_old_generators.
double octave_rand::do_seed | ( | void | ) | [private] |
Definition at line 112 of file oct-rand.cc.
References d, F77_FUNC(), oct_mach_info::flt_fmt_ieee_big_endian, getsd(), and oct_mach_info::native_float_format().
ColumnVector octave_rand::do_state | ( | const std::string & | d | ) | [private] |
Definition at line 182 of file oct-rand.cc.
References current_distribution, get_dist_id(), and rand_states.
void octave_rand::do_state | ( | const ColumnVector & | s, | |
const std::string & | d | |||
) | [private] |
Definition at line 188 of file oct-rand.cc.
References current_distribution, get_dist_id(), get_internal_state(), rand_states, set_internal_state(), and use_old_generators.
void octave_rand::do_uniform_distribution | ( | void | ) | [private] |
Definition at line 301 of file oct-rand.cc.
References F77_FUNC(), switch_to_generator(), and uniform_dist.
Array< double > octave_rand::do_vector | ( | octave_idx_type | n, | |
double | a = 1. | |||
) | [private] |
Definition at line 456 of file oct-rand.cc.
References Array< T >::capacity(), Array< T >::clear(), fill(), and Array< T >::fortran_vec().
static void octave_rand::exponential_distribution | ( | void | ) | [inline, static] |
Definition at line 115 of file oct-rand.h.
Referenced by do_distribution(), and do_rand().
void octave_rand::fill | ( | octave_idx_type | len, | |
double * | v, | |||
double | a | |||
) | [private] |
Definition at line 609 of file oct-rand.cc.
References current_distribution, dignpoi(), expon_dist, F77_FUNC(), gamma_dist, MAKE_RAND, normal_dist, oct_fill_rande(), oct_fill_randg(), oct_fill_randn(), oct_fill_randp(), oct_fill_randu(), poisson_dist, save_state(), uniform_dist, use_old_generators, xisinf(), and xisnan().
Referenced by do_matrix(), do_nd_array(), and do_vector().
static void octave_rand::gamma_distribution | ( | void | ) | [inline, static] |
Definition at line 127 of file oct-rand.h.
Referenced by do_distribution(), and do_rand().
int octave_rand::get_dist_id | ( | const std::string & | d | ) | [private] |
Definition at line 546 of file oct-rand.cc.
References current_liboctave_error_handler.
Referenced by do_distribution(), do_reset(), and do_state().
ColumnVector octave_rand::get_internal_state | ( | void | ) | [private] |
Definition at line 525 of file oct-rand.cc.
References Array< T >::elem(), MT_N, oct_get_state(), and OCTAVE_LOCAL_BUFFER.
Referenced by do_reset(), do_state(), initialize_mersenne_twister(), and save_state().
void octave_rand::initialize_mersenne_twister | ( | void | ) | [private] |
Definition at line 499 of file oct-rand.cc.
References get_internal_state(), oct_init_by_entropy(), and rand_states.
Referenced by octave_rand().
void octave_rand::initialize_ranlib_generators | ( | void | ) | [private] |
Definition at line 478 of file oct-rand.cc.
References current_distribution, F77_FUNC(), force_to_fit_range(), octave_base_tm::hour(), octave_base_tm::mday(), octave_base_tm::min(), octave_base_tm::sec(), and setall().
Referenced by do_reset(), and octave_rand().
bool octave_rand::instance_ok | ( | void | ) | [static] |
Definition at line 88 of file oct-rand.cc.
References singleton_cleanup_list::add(), cleanup_instance(), instance, and octave_rand().
static Matrix octave_rand::matrix | ( | octave_idx_type | r, | |
octave_idx_type | c, | |||
double | a = 1.0 | |||
) | [inline, static] |
Definition at line 141 of file oct-rand.h.
static NDArray octave_rand::nd_array | ( | const dim_vector & | dims, | |
double | a = 1.0 | |||
) | [inline, static] |
Definition at line 148 of file oct-rand.h.
References NDArray.
Referenced by DEFUN_DLD(), and do_rand().
static void octave_rand::normal_distribution | ( | void | ) | [inline, static] |
Definition at line 109 of file oct-rand.h.
Referenced by do_distribution(), and do_rand().
static void octave_rand::poisson_distribution | ( | void | ) | [inline, static] |
Definition at line 121 of file oct-rand.h.
Referenced by do_distribution(), and do_rand().
static void octave_rand::reset | ( | void | ) | [inline, static] |
Definition at line 62 of file oct-rand.h.
Referenced by do_rand().
static void octave_rand::reset | ( | const std::string & | d | ) | [inline, static] |
Definition at line 83 of file oct-rand.h.
void octave_rand::save_state | ( | void | ) | [private] |
Definition at line 540 of file oct-rand.cc.
References current_distribution, get_internal_state(), and rand_states.
Referenced by do_scalar(), and fill().
static void octave_rand::seed | ( | double | s | ) | [inline, static] |
Definition at line 55 of file oct-rand.h.
static double octave_rand::seed | ( | void | ) | [inline, static] |
void octave_rand::set_internal_state | ( | const ColumnVector & | s | ) | [private] |
Definition at line 568 of file oct-rand.cc.
References Array< T >::elem(), Array< T >::length(), MT_N, oct_init_by_array(), oct_set_state(), and OCTAVE_LOCAL_BUFFER.
Referenced by do_state(), and switch_to_generator().
static ColumnVector octave_rand::state | ( | const std::string & | d = std::string () |
) | [inline, static] |
static void octave_rand::state | ( | const ColumnVector & | s, | |
const std::string & | d = std::string () | |||
) | [inline, static] |
Definition at line 75 of file oct-rand.h.
References d.
void octave_rand::switch_to_generator | ( | int | dist | ) | [private] |
Definition at line 585 of file oct-rand.cc.
References current_distribution, rand_states, and set_internal_state().
Referenced by do_exponential_distribution(), do_gamma_distribution(), do_normal_distribution(), do_poisson_distribution(), and do_uniform_distribution().
static void octave_rand::uniform_distribution | ( | void | ) | [inline, static] |
Definition at line 103 of file oct-rand.h.
Referenced by do_distribution(), and do_rand().
static Array<double> octave_rand::vector | ( | octave_idx_type | n, | |
double | a = 1.0 | |||
) | [inline, static] |
Definition at line 154 of file oct-rand.h.
int octave_rand::current_distribution [private] |
Definition at line 176 of file oct-rand.h.
Referenced by do_distribution(), do_reset(), do_scalar(), do_state(), fill(), initialize_ranlib_generators(), save_state(), and switch_to_generator().
octave_rand * octave_rand::instance = 0 [static, private] |
Definition at line 161 of file oct-rand.h.
Referenced by instance_ok().
std::map<int, ColumnVector> octave_rand::rand_states [private] |
Definition at line 183 of file oct-rand.h.
Referenced by do_reset(), do_state(), initialize_mersenne_twister(), save_state(), and switch_to_generator().
bool octave_rand::use_old_generators [private] |
Definition at line 180 of file oct-rand.h.
Referenced by do_reset(), do_scalar(), do_seed(), do_state(), and fill().