26 #if ! defined (octave_oct_rand_h)
27 #define octave_oct_rand_h 1
29 #include "octave-config.h"
52 OCTAVE_DISABLE_COPY_MOVE (
rand)
56 static bool instance_ok ();
61 return (instance_ok ()
66 static void seed (
double s)
69 s_instance->do_seed (s);
76 s_instance->do_reset ();
82 return instance_ok () ? s_instance->do_state (
d) :
uint32NDArray ();
87 const std::string&
d =
"")
90 s_instance->do_state (s,
d);
94 static void reset (
const std::string&
d)
97 s_instance->do_reset (
d);
103 return instance_ok () ? s_instance->do_distribution () :
"";
111 s_instance->do_distribution (
d);
117 s_instance->do_uniform_distribution ();
123 s_instance->do_normal_distribution ();
129 s_instance->do_exponential_distribution ();
135 s_instance->do_poisson_distribution ();
141 s_instance->do_gamma_distribution ();
147 return (instance_ok ()
154 return (instance_ok ()
161 return instance_ok () ? s_instance->do_vector (
n, a) :
Array<double> ();
167 return instance_ok () ? s_instance->do_vector (
n, a) :
Array<float> ();
174 return instance_ok () ? s_instance->do_nd_array (dims, a) :
NDArray ();
181 return (instance_ok ()
182 ? s_instance->do_float_nd_array (dims, a) :
FloatNDArray ());
187 static rand *s_instance;
189 static void cleanup_instance ()
190 {
delete s_instance; s_instance =
nullptr; }
203 int m_current_distribution;
207 bool m_use_old_generators;
210 std::map<int, uint32NDArray> m_rand_states;
235 OCTAVE_API void do_distribution (
const std::string&
d);
241 OCTAVE_API void do_exponential_distribution ();
250 template <
typename T>
OCTAVE_API T uniform ();
254 template <
typename T>
OCTAVE_API T exponential ();
256 template <
typename T>
OCTAVE_API T poisson (T a);
261 template <
typename T>
OCTAVE_API T do_scalar (T a = 1);
274 do_float_nd_array (
const dim_vector& dims,
float a = 1.);
278 OCTAVE_API void initialize_ranlib_generators ();
280 OCTAVE_API void initialize_mersenne_twister ();
290 OCTAVE_API void switch_to_generator (
int dist);
297 OCTAVE_END_NAMESPACE(
octave)
Vector representing the dimensions (size) of an Array.
static FloatNDArray float_nd_array(const dim_vector &dims, float a=1.0)
static uint32NDArray state(const std::string &d="")
static Array< float > float_vector(octave_idx_type n, float a=1.0)
static void distribution(const std::string &d)
static NDArray nd_array(const dim_vector &dims, double a=1.0)
static void uniform_distribution()
static double scalar(double a=1.0)
static void seed(double s)
static void exponential_distribution()
static float float_scalar(float a=1.0)
static void reset(const std::string &d)
static void gamma_distribution()
static void state(const uint32NDArray &s, const std::string &d="")
static Array< double > vector(octave_idx_type n, double a=1.0)
static std::string distribution()
static void normal_distribution()
static void poisson_distribution()
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
intNDArray< octave_uint32 > uint32NDArray