73 F77_FUNC (setcgn, SETCGN) (
const int32_t&);
102 (*current_liboctave_error_handler)
103 (
"unable to create octave_rand object!");
114 union d2i {
double d; int32_t i[2]; };
135 assert (hi > lo && lo >= 0 && hi > lo);
153 union d2i {
double d; int32_t i[2]; };
198 if (old_dist != new_dist)
205 if (old_dist != new_dist)
220 if (old_dist != new_dist)
226 if (old_dist != new_dist)
246 retval =
"exponential";
258 (*current_liboctave_error_handler)
294 (*current_liboctave_error_handler)
295 (
"rand: invalid distribution ID = %d", id);
381 (*current_liboctave_error_handler)
411 (*current_liboctave_error_handler)
430 double dretval = 0.0;
457 if (da <= 0.0 || !
xfinite (a))
464 (*current_liboctave_error_handler)
496 (*current_liboctave_error_handler)
519 (*current_liboctave_error_handler) (
"rand: invalid negative argument");
536 (*current_liboctave_error_handler) (
"rand: invalid negative argument");
583 int hour = tm.
hour () + 1;
584 int minute = tm.
min () + 1;
585 int second = tm.
sec () + 1;
587 int32_t s0 = tm.
mday () * hour * minute * second;
588 int32_t s1 = hour * minute * second;
594 F77_FUNC (setcgn, SETCGN) (stored_distribution);
633 s.
elem (i) =
static_cast<double> (tmp[i]);
649 if (d ==
"uniform" || d ==
"rand")
651 else if (d ==
"normal" || d ==
"randn")
653 else if (d ==
"exponential" || d ==
"rande")
655 else if (d ==
"poisson" || d ==
"randp")
657 else if (d ==
"gamma" || d ==
"randg")
661 (
"rand: invalid distribution '%s'", d.c_str ());
681 d = fmod (d, TWOUP32);
684 u =
static_cast<uint32_t
> (
d);
718 #define MAKE_RAND(len) \
722 for (volatile octave_idx_type i = 0; i < len; i++) \
742 #define RAND_FUNC(x) F77_FUNC (dgenunf, DGENUNF) (0.0, 1.0, x)
753 #define RAND_FUNC(x) F77_FUNC (dgennor, DGENNOR) (0.0, 1.0, x)
764 #define RAND_FUNC(x) F77_FUNC (dgenexp, DGENEXP) (1.0, x)
776 #define RAND_FUNC(x) x = octave_NaN;
784 #define RAND_FUNC(x) F77_FUNC (dignpoi, DIGNPOI) (a, x)
797 #define RAND_FUNC(x) x = octave_NaN;
801 #define RAND_FUNC(x) F77_FUNC (dgengam, DGENGAM) (1.0, a, x)
810 (*current_liboctave_error_handler)
831 #define RAND_FUNC(x) F77_FUNC (dgenunf, DGENUNF) (0.0, 1.0, x)
842 #define RAND_FUNC(x) F77_FUNC (dgennor, DGENNOR) (0.0, 1.0, x)
853 #define RAND_FUNC(x) F77_FUNC (dgenexp, DGENEXP) (1.0, x)
866 #define RAND_FUNC(x) x = octave_NaN;
874 #define RAND_FUNC(x) F77_FUNC (dignpoi, DIGNPOI) (da, x)
887 if (da <= 0.0 || !
xfinite (a))
888 #define RAND_FUNC(x) x = octave_NaN;
892 #define RAND_FUNC(x) F77_FUNC (dgengam, DGENGAM) (1.0, da, x)
901 (*current_liboctave_error_handler)
subroutine setsd(iseed1, iseed2)
void oct_init_by_array(uint32_t *init_key, int key_length)
Array< float > do_float_vector(octave_idx_type n, float a=1.)
static bool instance_ok(void)
void oct_fill_rande(octave_idx_type n, double *p)
NDArray do_nd_array(const dim_vector &dims, double a=1.)
void oct_fill_randp(double L, octave_idx_type n, double *p)
static void exponential_distribution(void)
subroutine dignpoi(mu, result)
float oct_float_randu(void)
void do_poisson_distribution(void)
void do_exponential_distribution(void)
void oct_fill_float_randn(octave_idx_type n, float *p)
static void cleanup_instance(void)
void oct_fill_randn(octave_idx_type n, double *p)
void initialize_ranlib_generators(void)
F77_RET_T F77_FUNC(dgennor, DGENNOR)(const double &
void oct_fill_float_rande(octave_idx_type n, float *p)
void oct_fill_float_randp(float FL, octave_idx_type n, float *p)
T & elem(octave_idx_type n)
float oct_float_rande(void)
void do_normal_distribution(void)
double do_scalar(double a=1.)
F77_RET_T const double const double double * d
ColumnVector do_state(const std::string &d)
float oct_float_randg(float a)
void fill(octave_idx_type len, double *v, double a)
void initialize_mersenne_twister(void)
void oct_init_by_entropy(void)
void switch_to_generator(int dist)
static uint32_t double2uint32(double d)
liboctave_error_handler current_liboctave_error_handler
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
subroutine dgenexp(av, result)
static void gamma_distribution(void)
void oct_fill_randu(octave_idx_type n, double *p)
std::map< int, ColumnVector > rand_states
FloatNDArray do_float_nd_array(const dim_vector &dims, float a=1.)
Array< double > do_vector(octave_idx_type n, double a=1.)
static void poisson_distribution(void)
octave_idx_type capacity(void) const
Number of elements in the array.
subroutine dgengam(a, r, result)
void oct_fill_float_randu(octave_idx_type n, float *p)
float oct_float_randn(void)
bool all_zero(void) const
subroutine setall(iseed1, iseed2)
void oct_fill_float_randg(float a, octave_idx_type n, float *r)
Handles the reference counting for all the derived classes.
charNDArray max(char d, const charNDArray &m)
octave_idx_type length(void) const
Number of elements in the array.
void do_uniform_distribution(void)
void oct_set_state(uint32_t *save)
static float_format native_float_format(void)
double oct_randp(double L)
static octave_rand * instance
static void normal_distribution(void)
double oct_randg(double a)
subroutine dgennor(av, sd, result)
subroutine getsd(iseed1, iseed2)
std::string do_distribution(void)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
void set_internal_state(const ColumnVector &s)
const T * fortran_vec(void) const
static void uniform_distribution(void)
static int32_t force_to_fit_range(int32_t i, int32_t lo, int32_t hi)
void oct_fill_randg(double a, octave_idx_type n, double *r)
ColumnVector get_internal_state(void)
void oct_get_state(uint32_t *save)