23 #if defined (HAVE_CONFIG_H) 71 (*current_liboctave_error_handler)
72 (
"unable to create octave_rand object!");
80 union d2i {
double d; int32_t
i[2]; };
102 assert (hi > lo && lo >= 0 && hi > lo);
104 i = (
i > 0 ?
i : -
i);
120 union d2i {
double d; int32_t
i[2]; };
166 if (old_dist != new_dist)
173 if (old_dist != new_dist)
188 if (old_dist != new_dist)
194 if (old_dist != new_dist)
226 (*current_liboctave_error_handler)
262 (*current_liboctave_error_handler)
263 (
"rand: invalid distribution ID = %d",
id);
348 (*current_liboctave_error_handler)
378 (*current_liboctave_error_handler)
429 (*current_liboctave_error_handler)
460 (*current_liboctave_error_handler)
483 (*current_liboctave_error_handler) (
"rand: invalid negative argument");
500 (*current_liboctave_error_handler) (
"rand: invalid negative argument");
510 if (!
dims.all_zero ())
525 if (!
dims.all_zero ())
548 int minute = tm.
min () + 1;
549 int second = tm.
sec () + 1;
551 int32_t s0 = tm.
mday () *
hour * minute * second;
552 int32_t s1 =
hour * minute * second;
558 F77_FUNC (setcgn, SETCGN) (stored_distribution);
612 if (
d ==
"uniform" ||
d ==
"rand")
614 else if (
d ==
"normal" ||
d ==
"randn")
616 else if (
d ==
"exponential" ||
d ==
"rande")
618 else if (
d ==
"poisson" ||
d ==
"randp")
620 else if (
d ==
"gamma" ||
d ==
"randg")
624 (
"rand: invalid distribution '%s'",
d.c_str ());
634 const uint32_t *sdata = reinterpret_cast <
const uint32_t *> (
s.data ());
663 std::generate_n (v, len, [](
void) {
double x;
F77_FUNC (
dgenunf, DGENUNF) (0.0, 1.0,
x);
return x; });
670 std::generate_n (v, len, [](
void) {
double x;
F77_FUNC (
dgennor, DGENNOR) (0.0, 1.0,
x);
return x; });
677 std::generate_n (v, len, [](
void) {
double x;
F77_FUNC (
dgenexp, DGENEXP) (1.0,
x);
return x; });
692 std::generate_n (v, len, [
a](
void) {
double x;
F77_FUNC (
dignpoi, DIGNPOI) (
a,
x);
return x; });
705 std::generate_n (v, len, [
a](
void) {
double x;
F77_FUNC (
dgengam, DGENGAM) (1.0,
a,
x);
return x; });
712 (*current_liboctave_error_handler)
732 std::generate_n (v, len, [](
void) {
float x;
F77_FUNC (
fgenunf, FGENUNF) (0.0f, 1.0f,
x);
return x; });
739 std::generate_n (v, len, [](
void) {
float x;
F77_FUNC (
fgennor, FGENNOR) (0.0f, 1.0f,
x);
return x; });
746 std::generate_n (v, len, [](
void) {
float x;
F77_FUNC (
fgenexp, FGENEXP) (1.0f,
x);
return x; });
774 std::generate_n (v, len, [
a](
void) {
float x;
F77_FUNC (
fgengam, FGENGAM) (1.0f,
a,
x);
return x; });
781 (*current_liboctave_error_handler)
for fields that display a single padding can be changed or inhibited by following the hour(hh:mm:ss [AP]M). tem %R Time
subroutine setsd(iseed1, iseed2)
Array< float > do_float_vector(octave_idx_type n, float a=1.)
static bool instance_ok(void)
NDArray do_nd_array(const dim_vector &dims, double a=1.)
float oct_float_randu(void)
static void exponential_distribution(void)
subroutine dignpoi(mu, result)
void do_poisson_distribution(void)
void oct_get_state(uint32_t *save)
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE * f
void do_exponential_distribution(void)
OCTAVE_NORETURN liboctave_error_handler current_liboctave_error_handler
uint32NDArray do_state(const std::string &d)
static void cleanup_instance(void)
subroutine fgenunf(low, high, result)
void initialize_ranlib_generators(void)
void set_internal_state(const uint32NDArray &s)
void oct_fill_randg(double a, octave_idx_type n, double *r)
void do_normal_distribution(void)
double do_scalar(double a=1.)
void oct_fill_float_randu(octave_idx_type n, float *p)
void oct_set_state(const uint32_t *save)
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
void fill(octave_idx_type len, double *v, double a)
void oct_fill_randu(octave_idx_type n, double *p)
void initialize_mersenne_twister(void)
void switch_to_generator(int dist)
double oct_randp(double L)
float do_float_scalar(float a=1.)
int get_dist_id(const std::string &d)
subroutine dgenunf(low, high, result)
void do_gamma_distribution(void)
static std::string current_distribution
float oct_float_randn(void)
subroutine dgenexp(av, result)
octave_idx_type numel(const octave_value_list &idx)
static void gamma_distribution(void)
float_format native_float_format(void)
FloatNDArray do_float_nd_array(const dim_vector &dims, float a=1.)
Array< double > do_vector(octave_idx_type n, double a=1.)
float oct_float_randg(float a)
static void poisson_distribution(void)
void oct_fill_randn(octave_idx_type n, double *p)
subroutine dgengam(a, r, result)
the exceeded dimensions are set to if fewer subscripts than dimensions are the exceeding dimensions are merged into the final requested dimension For consider the following dims
double oct_randg(double a)
void oct_fill_float_randp(float FL, octave_idx_type n, float *p)
F77_RET_T F77_FUNC(xerbla, XERBLA)
subroutine fgenexp(av, result)
subroutine setall(iseed1, iseed2)
subroutine fgennor(av, sd, result)
void oct_fill_float_randn(octave_idx_type n, float *p)
N Dimensional Array with copy-on-write semantics.
void do_uniform_distribution(void)
void oct_fill_float_randg(float a, octave_idx_type n, float *r)
static octave_rand * instance
OCTAVE_EXPORT octave_value_list or N dimensional array whose elements are all equal to the IEEE symbol NaN(Not a Number). NaN is the result of operations which do not produce a well defined 0 result. Common operations which produce a NaN are arithmetic with infinity ex($\infty - \infty$)
static void normal_distribution(void)
std::map< int, uint32NDArray > rand_states
subroutine dgennor(av, sd, result)
float oct_float_rande(void)
subroutine getsd(iseed1, iseed2)
void oct_fill_rande(octave_idx_type n, double *p)
std::string do_distribution(void)
void oct_init_by_entropy(void)
subroutine fignpoi(mu, result)
subroutine fgengam(a, r, result)
Vector representing the dimensions (size) of an Array.
static void uniform_distribution(void)
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
void oct_fill_float_rande(octave_idx_type n, float *p)
static int32_t force_to_fit_range(int32_t i, int32_t lo, int32_t hi)
void oct_init_by_array(const uint32_t *init_key, const int key_length)
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE * x
void oct_fill_randp(double L, octave_idx_type n, double *p)
uint32NDArray get_internal_state(void)