GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
oct-rand.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2003-2017 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if defined (HAVE_CONFIG_H)
24 # include "config.h"
25 #endif
26 
27 #include <cstdint>
28 
29 #include <map>
30 #include <vector>
31 
32 #include "data-conv.h"
33 #include "f77-fcn.h"
34 #include "lo-error.h"
35 #include "lo-ieee.h"
36 #include "lo-mappers.h"
37 #include "lo-ranlib-proto.h"
38 #include "mach-info.h"
39 #include "oct-locbuf.h"
40 #include "oct-rand.h"
41 #include "oct-time.h"
42 #include "randgamma.h"
43 #include "randmtzig.h"
44 #include "randpoisson.h"
45 #include "singleton-cleanup.h"
46 
48 
50  : current_distribution (uniform_dist), use_old_generators (false),
51  rand_states ()
52 {
54 
56 }
57 
58 bool
60 {
61  bool retval = true;
62 
63  if (! instance)
64  {
65  instance = new octave_rand ();
66 
67  if (instance)
69  }
70 
71  if (! instance)
72  (*current_liboctave_error_handler)
73  ("unable to create octave_rand object!");
74 
75  return retval;
76 }
77 
78 double
80 {
81  union d2i { double d; int32_t i[2]; };
82  union d2i u;
83 
85 
86  switch (ff)
87  {
89  F77_FUNC (getsd, GETSD) (u.i[1], u.i[0]);
90  break;
91  default:
92  F77_FUNC (getsd, GETSD) (u.i[0], u.i[1]);
93  break;
94  }
95 
96  return u.d;
97 }
98 
99 static int32_t
100 force_to_fit_range (int32_t i, int32_t lo, int32_t hi)
101 {
102  assert (hi > lo && lo >= 0 && hi > lo);
103 
104  i = i > 0 ? i : -i;
105 
106  if (i < lo)
107  i = lo;
108  else if (i > hi)
109  i = i % hi;
110 
111  return i;
112 }
113 
114 void
116 {
117  use_old_generators = true;
118 
119  int i0, i1;
120  union d2i { double d; int32_t i[2]; };
121  union d2i u;
122  u.d = s;
123 
125 
126  switch (ff)
127  {
129  i1 = force_to_fit_range (u.i[0], 1, 2147483563);
130  i0 = force_to_fit_range (u.i[1], 1, 2147483399);
131  break;
132  default:
133  i0 = force_to_fit_range (u.i[0], 1, 2147483563);
134  i1 = force_to_fit_range (u.i[1], 1, 2147483399);
135  break;
136  }
137 
138  F77_FUNC (setsd, SETSD) (i0, i1);
139 }
140 
141 void
143 {
144  use_old_generators = true;
146 }
147 
150 {
151  return rand_states[d.empty () ? current_distribution : get_dist_id (d)];
152 }
153 
154 void
156 {
157  use_old_generators = false;
158 
159  int old_dist = current_distribution;
160 
161  int new_dist = d.empty () ? current_distribution : get_dist_id (d);
162 
163  ColumnVector saved_state;
164 
165  if (old_dist != new_dist)
166  saved_state = get_internal_state ();
167 
168  set_internal_state (s);
169 
170  rand_states[new_dist] = get_internal_state ();
171 
172  if (old_dist != new_dist)
173  rand_states[old_dist] = saved_state;
174 }
175 
176 void
178 {
179  use_old_generators = false;
180 
181  int old_dist = current_distribution;
182 
183  int new_dist = d.empty () ? current_distribution : get_dist_id (d);
184 
185  ColumnVector saved_state;
186 
187  if (old_dist != new_dist)
188  saved_state = get_internal_state ();
189 
191  rand_states[new_dist] = get_internal_state ();
192 
193  if (old_dist != new_dist)
194  rand_states[old_dist] = saved_state;
195 }
196 
199 {
201 
202  switch (current_distribution)
203  {
204  case uniform_dist:
205  retval = "uniform";
206  break;
207 
208  case normal_dist:
209  retval = "normal";
210  break;
211 
212  case expon_dist:
213  retval = "exponential";
214  break;
215 
216  case poisson_dist:
217  retval = "poisson";
218  break;
219 
220  case gamma_dist:
221  retval = "gamma";
222  break;
223 
224  default:
225  (*current_liboctave_error_handler)
226  ("rand: invalid distribution ID = %d", current_distribution);
227  break;
228  }
229 
230  return retval;
231 }
232 
233 void
235 {
236  int id = get_dist_id (d);
237 
238  switch (id)
239  {
240  case uniform_dist:
242  break;
243 
244  case normal_dist:
246  break;
247 
248  case expon_dist:
250  break;
251 
252  case poisson_dist:
254  break;
255 
256  case gamma_dist:
258  break;
259 
260  default:
261  (*current_liboctave_error_handler)
262  ("rand: invalid distribution ID = %d", id);
263  break;
264  }
265 }
266 
267 void
269 {
271 
272  F77_FUNC (setcgn, SETCGN) (uniform_dist);
273 }
274 
275 void
277 {
279 
280  F77_FUNC (setcgn, SETCGN) (normal_dist);
281 }
282 
283 void
285 {
287 
288  F77_FUNC (setcgn, SETCGN) (expon_dist);
289 }
290 
291 void
293 {
295 
296  F77_FUNC (setcgn, SETCGN) (poisson_dist);
297 }
298 
299 void
301 {
303 
304  F77_FUNC (setcgn, SETCGN) (gamma_dist);
305 }
306 
307 double
309 {
310  double retval = 0.0;
311 
312  if (use_old_generators)
313  {
314  switch (current_distribution)
315  {
316  case uniform_dist:
317  F77_FUNC (dgenunf, DGENUNF) (0.0, 1.0, retval);
318  break;
319 
320  case normal_dist:
321  F77_FUNC (dgennor, DGENNOR) (0.0, 1.0, retval);
322  break;
323 
324  case expon_dist:
325  F77_FUNC (dgenexp, DGENEXP) (1.0, retval);
326  break;
327 
328  case poisson_dist:
329  if (a < 0.0 || ! octave::math::finite (a))
331  else
332  {
333  // workaround bug in ignpoi, by calling with different Mu
334  F77_FUNC (dignpoi, DIGNPOI) (a + 1, retval);
335  F77_FUNC (dignpoi, DIGNPOI) (a, retval);
336  }
337  break;
338 
339  case gamma_dist:
340  if (a <= 0.0 || ! octave::math::finite (a))
342  else
343  F77_FUNC (dgengam, DGENGAM) (1.0, a, retval);
344  break;
345 
346  default:
347  (*current_liboctave_error_handler)
348  ("rand: invalid distribution ID = %d", current_distribution);
349  break;
350  }
351  }
352  else
353  {
354  switch (current_distribution)
355  {
356  case uniform_dist:
357  retval = oct_randu ();
358  break;
359 
360  case normal_dist:
361  retval = oct_randn ();
362  break;
363 
364  case expon_dist:
365  retval = oct_rande ();
366  break;
367 
368  case poisson_dist:
369  retval = oct_randp (a);
370  break;
371 
372  case gamma_dist:
373  retval = oct_randg (a);
374  break;
375 
376  default:
377  (*current_liboctave_error_handler)
378  ("rand: invalid distribution ID = %d", current_distribution);
379  break;
380  }
381 
382  save_state ();
383  }
384 
385  return retval;
386 }
387 
388 float
390 {
391  float retval = 0.0;
392 
393  if (use_old_generators)
394  {
395  double da = a;
396  double dretval = 0.0;
397  switch (current_distribution)
398  {
399  case uniform_dist:
400  F77_FUNC (dgenunf, DGENUNF) (0.0, 1.0, dretval);
401  break;
402 
403  case normal_dist:
404  F77_FUNC (dgennor, DGENNOR) (0.0, 1.0, dretval);
405  break;
406 
407  case expon_dist:
408  F77_FUNC (dgenexp, DGENEXP) (1.0, dretval);
409  break;
410 
411  case poisson_dist:
412  if (da < 0.0 || ! octave::math::finite (a))
414  else
415  {
416  // workaround bug in ignpoi, by calling with different Mu
417  F77_FUNC (dignpoi, DIGNPOI) (da + 1, dretval);
418  F77_FUNC (dignpoi, DIGNPOI) (da, dretval);
419  }
420  break;
421 
422  case gamma_dist:
423  if (da <= 0.0 || ! octave::math::finite (a))
425  else
426  F77_FUNC (dgengam, DGENGAM) (1.0, da, dretval);
427  break;
428 
429  default:
430  (*current_liboctave_error_handler)
431  ("rand: invalid distribution ID = %d", current_distribution);
432  break;
433  }
434  retval = dretval;
435  }
436  else
437  {
438  switch (current_distribution)
439  {
440  case uniform_dist:
441  retval = oct_float_randu ();
442  break;
443 
444  case normal_dist:
445  retval = oct_float_randn ();
446  break;
447 
448  case expon_dist:
449  retval = oct_float_rande ();
450  break;
451 
452  case poisson_dist:
453  // Keep poisson distribution in double precision for accuracy
454  retval = oct_randp (a);
455  break;
456 
457  case gamma_dist:
458  retval = oct_float_randg (a);
459  break;
460 
461  default:
462  (*current_liboctave_error_handler)
463  ("rand: invalid distribution ID = %d", current_distribution);
464  break;
465  }
466 
467  save_state ();
468  }
469 
470  return retval;
471 }
472 
475 {
477 
478  if (n > 0)
479  {
480  retval.clear (n, 1);
481 
482  fill (retval.numel (), retval.fortran_vec (), a);
483  }
484  else if (n < 0)
485  (*current_liboctave_error_handler) ("rand: invalid negative argument");
486 
487  return retval;
488 }
489 
492 {
494 
495  if (n > 0)
496  {
497  retval.clear (n, 1);
498 
499  fill (retval.numel (), retval.fortran_vec (), a);
500  }
501  else if (n < 0)
502  (*current_liboctave_error_handler) ("rand: invalid negative argument");
503 
504  return retval;
505 }
506 
507 NDArray
509 {
510  NDArray retval;
511 
512  if (! dims.all_zero ())
513  {
514  retval.clear (dims);
515 
516  fill (retval.numel (), retval.fortran_vec (), a);
517  }
518 
519  return retval;
520 }
521 
524 {
526 
527  if (! dims.all_zero ())
528  {
529  retval.clear (dims);
530 
531  fill (retval.numel (), retval.fortran_vec (), a);
532  }
533 
534  return retval;
535 }
536 
537 // Make the random number generator give us a different sequence every
538 // time we start octave unless we specifically set the seed. The
539 // technique used below will cycle monthly, but it does seem to
540 // work ok to give fairly different seeds each time Octave starts.
541 
542 void
544 {
546  int stored_distribution = current_distribution;
547  F77_FUNC (setcgn, SETCGN) (uniform_dist);
548 
549  int hour = tm.hour () + 1;
550  int minute = tm.min () + 1;
551  int second = tm.sec () + 1;
552 
553  int32_t s0 = tm.mday () * hour * minute * second;
554  int32_t s1 = hour * minute * second;
555 
556  s0 = force_to_fit_range (s0, 1, 2147483563);
557  s1 = force_to_fit_range (s1, 1, 2147483399);
558 
559  F77_FUNC (setall, SETALL) (s0, s1);
560  F77_FUNC (setcgn, SETCGN) (stored_distribution);
561 }
562 
563 void
565 {
567 
569 
571 
573  s = get_internal_state ();
575 
577  s = get_internal_state ();
579 
581  s = get_internal_state ();
583 
585  s = get_internal_state ();
587 }
588 
591 {
592  ColumnVector s (MT_N + 1);
593 
594  OCTAVE_LOCAL_BUFFER (uint32_t, tmp, MT_N + 1);
595 
596  oct_get_state (tmp);
597 
598  for (octave_idx_type i = 0; i <= MT_N; i++)
599  s.elem (i) = static_cast<double> (tmp[i]);
600 
601  return s;
602 }
603 
604 void
606 {
608 }
609 
610 int
612 {
613  int retval = unknown_dist;
614 
615  if (d == "uniform" || d == "rand")
616  retval = uniform_dist;
617  else if (d == "normal" || d == "randn")
618  retval = normal_dist;
619  else if (d == "exponential" || d == "rande")
620  retval = expon_dist;
621  else if (d == "poisson" || d == "randp")
622  retval = poisson_dist;
623  else if (d == "gamma" || d == "randg")
624  retval = gamma_dist;
625  else
627  ("rand: invalid distribution '%s'", d.c_str ());
628 
629  return retval;
630 }
631 
632 // Guarantee reproducible conversion of negative initialization values to
633 // random number algorithm. Note that Matlab employs slightly different rules.
634 // 1) Seed saturates at 2^32-1 for any value larger than that.
635 // 2) NaN, Inf are translated to 2^32-1.
636 // 3) -Inf is translated to 0.
637 static uint32_t
638 double2uint32 (double d)
639 {
640  uint32_t u;
641  static const double TWOUP32 = std::numeric_limits<uint32_t>::max() + 1.0;
642 
643  if (! octave::math::finite (d))
644  u = 0;
645  else
646  {
647  d = fmod (d, TWOUP32);
648  if (d < 0)
649  d += TWOUP32;
650  u = static_cast<uint32_t> (d);
651  }
652 
653  return u;
654 }
655 
656 void
658 {
659  octave_idx_type len = s.numel ();
660  octave_idx_type n = len < MT_N + 1 ? len : MT_N + 1;
661 
662  OCTAVE_LOCAL_BUFFER (uint32_t, tmp, MT_N + 1);
663 
664  for (octave_idx_type i = 0; i < n; i++)
665  tmp[i] = double2uint32 (s.elem (i));
666 
667  if (len == MT_N + 1 && tmp[MT_N] <= MT_N && tmp[MT_N] > 0)
668  oct_set_state (tmp);
669  else
670  oct_init_by_array (tmp, len);
671 }
672 
673 void
675 {
676  if (dist != current_distribution)
677  {
678  current_distribution = dist;
679 
681  }
682 }
683 
684 #define MAKE_RAND(len) \
685  do \
686  { \
687  double val; \
688  for (volatile octave_idx_type i = 0; i < len; i++) \
689  { \
690  octave_quit (); \
691  RAND_FUNC (val); \
692  v[i] = val; \
693  } \
694  } \
695  while (0)
696 
697 void
698 octave_rand::fill (octave_idx_type len, double *v, double a)
699 {
700  if (len < 1)
701  return;
702 
703  switch (current_distribution)
704  {
705  case uniform_dist:
706  if (use_old_generators)
707  {
708 #define RAND_FUNC(x) F77_FUNC (dgenunf, DGENUNF) (0.0, 1.0, x)
709  MAKE_RAND (len);
710 #undef RAND_FUNC
711  }
712  else
713  oct_fill_randu (len, v);
714  break;
715 
716  case normal_dist:
717  if (use_old_generators)
718  {
719 #define RAND_FUNC(x) F77_FUNC (dgennor, DGENNOR) (0.0, 1.0, x)
720  MAKE_RAND (len);
721 #undef RAND_FUNC
722  }
723  else
724  oct_fill_randn (len, v);
725  break;
726 
727  case expon_dist:
728  if (use_old_generators)
729  {
730 #define RAND_FUNC(x) F77_FUNC (dgenexp, DGENEXP) (1.0, x)
731  MAKE_RAND (len);
732 #undef RAND_FUNC
733  }
734  else
735  oct_fill_rande (len, v);
736  break;
737 
738  case poisson_dist:
739  if (use_old_generators)
740  {
741  if (a < 0.0 || ! octave::math::finite (a))
742 #define RAND_FUNC(x) x = octave::numeric_limits<double>::NaN ();
743  MAKE_RAND (len);
744 #undef RAND_FUNC
745  else
746  {
747  // workaround bug in ignpoi, by calling with different Mu
748  double tmp;
749  F77_FUNC (dignpoi, DIGNPOI) (a + 1, tmp);
750 #define RAND_FUNC(x) F77_FUNC (dignpoi, DIGNPOI) (a, x)
751  MAKE_RAND (len);
752 #undef RAND_FUNC
753  }
754  }
755  else
756  oct_fill_randp (a, len, v);
757  break;
758 
759  case gamma_dist:
760  if (use_old_generators)
761  {
762  if (a <= 0.0 || ! octave::math::finite (a))
763 #define RAND_FUNC(x) x = octave::numeric_limits<double>::NaN ();
764  MAKE_RAND (len);
765 #undef RAND_FUNC
766  else
767 #define RAND_FUNC(x) F77_FUNC (dgengam, DGENGAM) (1.0, a, x)
768  MAKE_RAND (len);
769 #undef RAND_FUNC
770  }
771  else
772  oct_fill_randg (a, len, v);
773  break;
774 
775  default:
776  (*current_liboctave_error_handler)
777  ("rand: invalid distribution ID = %d", current_distribution);
778  break;
779  }
780 
781  save_state ();
782 
783  return;
784 }
785 
786 void
787 octave_rand::fill (octave_idx_type len, float *v, float a)
788 {
789  if (len < 1)
790  return;
791 
792  switch (current_distribution)
793  {
794  case uniform_dist:
795  if (use_old_generators)
796  {
797 #define RAND_FUNC(x) F77_FUNC (dgenunf, DGENUNF) (0.0, 1.0, x)
798  MAKE_RAND (len);
799 #undef RAND_FUNC
800  }
801  else
802  oct_fill_float_randu (len, v);
803  break;
804 
805  case normal_dist:
806  if (use_old_generators)
807  {
808 #define RAND_FUNC(x) F77_FUNC (dgennor, DGENNOR) (0.0, 1.0, x)
809  MAKE_RAND (len);
810 #undef RAND_FUNC
811  }
812  else
813  oct_fill_float_randn (len, v);
814  break;
815 
816  case expon_dist:
817  if (use_old_generators)
818  {
819 #define RAND_FUNC(x) F77_FUNC (dgenexp, DGENEXP) (1.0, x)
820  MAKE_RAND (len);
821 #undef RAND_FUNC
822  }
823  else
824  oct_fill_float_rande (len, v);
825  break;
826 
827  case poisson_dist:
828  if (use_old_generators)
829  {
830  double da = a;
831  if (da < 0.0 || ! octave::math::finite (a))
832 #define RAND_FUNC(x) x = octave::numeric_limits<double>::NaN ();
833  MAKE_RAND (len);
834 #undef RAND_FUNC
835  else
836  {
837  // workaround bug in ignpoi, by calling with different Mu
838  double tmp;
839  F77_FUNC (dignpoi, DIGNPOI) (da + 1, tmp);
840 #define RAND_FUNC(x) F77_FUNC (dignpoi, DIGNPOI) (da, x)
841  MAKE_RAND (len);
842 #undef RAND_FUNC
843  }
844  }
845  else
846  oct_fill_float_randp (a, len, v);
847  break;
848 
849  case gamma_dist:
850  if (use_old_generators)
851  {
852  double da = a;
853  if (da <= 0.0 || ! octave::math::finite (a))
854 #define RAND_FUNC(x) x = octave::numeric_limits<double>::NaN ();
855  MAKE_RAND (len);
856 #undef RAND_FUNC
857  else
858 #define RAND_FUNC(x) F77_FUNC (dgengam, DGENGAM) (1.0, da, x)
859  MAKE_RAND (len);
860 #undef RAND_FUNC
861  }
862  else
863  oct_fill_float_randg (a, len, v);
864  break;
865 
866  default:
867  (*current_liboctave_error_handler)
868  ("rand: invalid distribution ID = %d", current_distribution);
869  break;
870  }
871 
872  save_state ();
873 
874  return;
875 }
uint32_t id
Definition: graphics.cc:11587
double oct_rande(void)
Definition: randmtzig.cc:627
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)
Definition: setsd.f:1
double oct_randu(void)
Definition: randmtzig.cc:408
Array< float > do_float_vector(octave_idx_type n, float a=1.)
Definition: oct-rand.cc:491
static bool instance_ok(void)
Definition: oct-rand.cc:59
OCTAVE_EXPORT octave_value_list return the value of the option it must match the dimension of the state and the relative tolerance must also be a vector of the same length tem it must match the dimension of the state and the absolute tolerance must also be a vector of the same length The local error test applied at each integration step is xample roup calculate Y_a and Y _d item Given calculate Y nd enumerate In either initial values for the given components are and initial guesses for the unknown components must also be provided as input Set this option to to solve the first or to solve the second(the default is 0, so you must provide a set of initial conditions that are consistent).If this option is set to a nonzero value
NDArray do_nd_array(const dim_vector &dims, double a=1.)
Definition: oct-rand.cc:508
float oct_float_randu(void)
Definition: randmtzig.cc:415
static void exponential_distribution(void)
Definition: oct-rand.h:118
void save_state(void)
Definition: oct-rand.cc:605
subroutine dignpoi(mu, result)
Definition: wrap.f:21
void do_poisson_distribution(void)
Definition: oct-rand.cc:292
int mday(void) const
Definition: oct-time.h:213
void oct_get_state(uint32_t *save)
Definition: randmtzig.cc:302
octave_idx_type numel(void) const
Number of elements in the array.
Definition: Array.h:363
void do_exponential_distribution(void)
Definition: oct-rand.cc:284
int min(void) const
Definition: oct-time.h:211
int sec(void) const
Definition: oct-time.h:210
OCTAVE_NORETURN liboctave_error_handler current_liboctave_error_handler
Definition: lo-error.c:38
#define MT_N
Definition: randmtzig.h:69
static void cleanup_instance(void)
Definition: oct-rand.h:181
void initialize_ranlib_generators(void)
Definition: oct-rand.cc:543
void oct_fill_randg(double a, octave_idx_type n, double *r)
Definition: randgamma.cc:95
T & elem(octave_idx_type n)
Definition: Array.h:482
void do_reset()
Definition: oct-rand.cc:142
u
Definition: lu.cc:138
s
Definition: file-io.cc:2682
octave_rand(void)
Definition: oct-rand.cc:49
int current_distribution
Definition: oct-rand.h:194
void do_normal_distribution(void)
Definition: oct-rand.cc:276
double do_scalar(double a=1.)
Definition: oct-rand.cc:308
void oct_fill_float_randu(octave_idx_type n, float *p)
Definition: randmtzig.cc:845
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &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 F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
ColumnVector do_state(const std::string &d)
Definition: oct-rand.cc:149
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
Definition: cellfun.cc:398
void fill(octave_idx_type len, double *v, double a)
Definition: oct-rand.cc:698
void oct_fill_randu(octave_idx_type n, double *p)
Definition: randmtzig.cc:821
void initialize_mersenne_twister(void)
Definition: oct-rand.cc:564
void switch_to_generator(int dist)
Definition: oct-rand.cc:674
double oct_randp(double L)
Definition: randpoisson.cc:508
static uint32_t double2uint32(double d)
Definition: oct-rand.cc:638
double do_seed(void)
Definition: oct-rand.cc:79
float do_float_scalar(float a=1.)
Definition: oct-rand.cc:389
int get_dist_id(const std::string &d)
Definition: oct-rand.cc:611
subroutine dgenunf(low, high, result)
Definition: wrap.f:6
void do_gamma_distribution(void)
Definition: oct-rand.cc:300
static std::string current_distribution
Definition: rand.cc:504
float oct_float_randn(void)
Definition: randmtzig.cc:752
subroutine dgenexp(av, result)
Definition: wrap.f:11
static void gamma_distribution(void)
Definition: oct-rand.h:130
static void add(fptr f)
std::map< int, ColumnVector > rand_states
Definition: oct-rand.h:201
FloatNDArray do_float_nd_array(const dim_vector &dims, float a=1.)
Definition: oct-rand.cc:523
double tmp
Definition: data.cc:6300
Array< double > do_vector(octave_idx_type n, double a=1.)
Definition: oct-rand.cc:474
is false
Definition: cellfun.cc:398
octave_value retval
Definition: data.cc:6294
float oct_float_randg(float a)
Definition: randgamma.cc:190
F77_RET_T F77_FUNC(xstopx, XSTOPX) const
Definition: f77-fcn.c:53
bool finite(double x)
Definition: lo-mappers.cc:367
static void poisson_distribution(void)
Definition: oct-rand.h:124
void oct_fill_randn(octave_idx_type n, double *p)
Definition: randmtzig.cc:829
subroutine dgengam(a, r, result)
Definition: wrap.f:16
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
Definition: sub2ind.cc:255
double oct_randg(double a)
Definition: randgamma.cc:135
bool all_zero(void) const
Definition: dim-vector.h:333
void oct_fill_float_randp(float FL, octave_idx_type n, float *p)
Definition: randpoisson.cc:547
subroutine setall(iseed1, iseed2)
Definition: setall.f:1
void oct_set_state(uint32_t *save)
Definition: randmtzig.cc:292
static float_format native_float_format(void)
Definition: mach-info.cc:162
void oct_fill_float_randn(octave_idx_type n, float *p)
Definition: randmtzig.cc:853
charNDArray max(char d, const charNDArray &m)
Definition: chNDArray.cc:228
void clear(void)
Definition: Array.cc:95
void do_uniform_distribution(void)
Definition: oct-rand.cc:268
void oct_fill_float_randg(float a, octave_idx_type n, float *r)
Definition: randgamma.cc:150
#define MAKE_RAND(len)
Definition: oct-rand.cc:684
=val(i)}if ode{val(i)}occurs in table i
Definition: lookup.cc:239
static octave_rand * instance
Definition: oct-rand.h:179
static void normal_distribution(void)
Definition: oct-rand.h:112
subroutine dgennor(av, sd, result)
Definition: wrap.f:1
float oct_float_rande(void)
Definition: randmtzig.cc:793
subroutine getsd(iseed1, iseed2)
Definition: getsd.f:1
bool use_old_generators
Definition: oct-rand.h:198
void oct_fill_rande(octave_idx_type n, double *p)
Definition: randmtzig.cc:837
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 $)
void oct_init_by_array(uint32_t *init_key, int key_length)
Definition: randmtzig.cc:213
std::string do_distribution(void)
Definition: oct-rand.cc:198
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
Definition: oct-locbuf.h:200
void oct_init_by_entropy(void)
Definition: randmtzig.cc:254
void set_internal_state(const ColumnVector &s)
Definition: oct-rand.cc:657
const T * fortran_vec(void) const
Definition: Array.h:584
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:87
double oct_randn(void)
Definition: randmtzig.cc:562
static void uniform_distribution(void)
Definition: oct-rand.h:106
int hour(void) const
Definition: oct-time.h:212
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
Definition: utils.cc:854
void oct_fill_float_rande(octave_idx_type n, float *p)
Definition: randmtzig.cc:861
static int32_t force_to_fit_range(int32_t i, int32_t lo, int32_t hi)
Definition: oct-rand.cc:100
ColumnVector get_internal_state(void)
Definition: oct-rand.cc:590
void oct_fill_randp(double L, octave_idx_type n, double *p)
Definition: randpoisson.cc:476