NEURON
ivocrand.cpp
Go to the documentation of this file.
1 #include <../../nrnconf.h>
2 
3 // definition of random number generation from the g++ library
4 
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include "random1.h"
8 
9 #include <InterViews/resource.h>
10 #include "classreg.h"
11 #include "oc2iv.h"
12 #include "nrnisaac.h"
13 
14 #include <vector>
15 #include <ocnotify.h>
16 #include "ocobserv.h"
17 #include <nrnran123.h>
18 
19 #include <RNG.h>
20 #include <ACG.h>
21 #include <MLCG.h>
22 #include <Random.h>
23 #include <Poisson.h>
24 #include <Normal.h>
25 #include <Uniform.h>
26 #include <Binomial.h>
27 #include <DiscUnif.h>
28 #include <Erlang.h>
29 #include <Geom.h>
30 #include <LogNorm.h>
31 #include <NegExp.h>
32 #include <RndInt.h>
33 #include <HypGeom.h>
34 #include <Weibull.h>
35 
36 #if HAVE_IV
37 #include "ivoc.h"
38 #endif
39 
40 #undef dmaxuint
41 #define dmaxuint 4294967295.
42 
43 extern "C" void nrn_random_play();
44 
45 class RandomPlay: public Observer, public Resource {
46  public:
47  RandomPlay(Rand*, double*);
48  virtual ~RandomPlay();
49  void play();
50  void list_remove();
51  virtual void update(Observable*);
52 
53  private:
54  Rand* r_;
55  double* px_;
56 };
57 
58 using RandomPlayList = std::vector<RandomPlay*>;
60 
61 extern "C" {
62 double nrn_random_pick(Rand* r);
63 void nrn_random_reset(Rand* r);
64 Rand* nrn_random_arg(int);
66 void nrn_set_random_sequence(Rand* r, long seq);
67 int nrn_random_isran123(Rand* r, uint32_t* id1, uint32_t* id2, uint32_t* id3);
68 int nrn_random123_setseq(Rand* r, uint32_t seq, char which);
69 int nrn_random123_getseq(Rand* r, uint32_t* seq, char* which);
70 } // extern "C"
71 
72 #include <mcran4.h>
73 
74 class NrnRandom123: public RNG {
75  public:
76  NrnRandom123(uint32_t id1, uint32_t id2, uint32_t id3 = 0);
77  virtual ~NrnRandom123();
78  virtual uint32_t asLong() {
79  return nrnran123_ipick(s_);
80  }
81  virtual double asDouble() {
82  return nrnran123_dblpick(s_);
83  }
84  virtual void reset() {
85  nrnran123_setseq(s_, 0, 0);
86  }
88 };
89 NrnRandom123::NrnRandom123(uint32_t id1, uint32_t id2, uint32_t id3) {
90  s_ = nrnran123_newstream3(id1, id2, id3);
91 }
94 }
95 
96 
97 // The decision that has to be made is whether each generator instance
98 // should have its own seed or only one seed for all. We choose separate
99 // seed for each but if arg not present or 0 then seed chosen by system.
100 
101 // the addition of ilow > 0 means that value is used for the lowindex
102 // instead of the mcell_ran4_init global 32 bit lowindex.
103 
104 class MCellRan4: public RNG {
105  public:
106  MCellRan4(uint32_t ihigh = 0, uint32_t ilow = 0);
107  virtual ~MCellRan4();
108  virtual uint32_t asLong() {
109  return (uint32_t) (ilow_ == 0 ? mcell_iran4(&ihigh_) : nrnRan4int(&ihigh_, ilow_));
110  }
111  virtual void reset() {
112  ihigh_ = orig_;
113  }
114  virtual double asDouble() {
115  return (ilow_ == 0 ? mcell_ran4a(&ihigh_) : nrnRan4dbl(&ihigh_, ilow_));
116  }
117  uint32_t ihigh_;
118  uint32_t orig_;
119  uint32_t ilow_;
120 
121  private:
122  static uint32_t cnt_;
123 };
124 
125 MCellRan4::MCellRan4(uint32_t ihigh, uint32_t ilow) {
126  ++cnt_;
127  ilow_ = ilow;
128  ihigh_ = ihigh;
129  if (ihigh_ == 0) {
130  ihigh_ = cnt_;
131  ihigh_ = (uint32_t) asLong();
132  }
133  orig_ = ihigh_;
134 }
136 
137 uint32_t MCellRan4::cnt_ = 0;
138 
139 class Isaac64: public RNG {
140  public:
141  Isaac64(uint32_t seed = 0);
142  virtual ~Isaac64();
143  virtual uint32_t asLong() {
144  return (uint32_t) nrnisaac_uint32_pick(rng_);
145  }
146  virtual void reset() {
148  }
149  virtual double asDouble() {
150  return nrnisaac_dbl_pick(rng_);
151  }
152  uint32_t seed() {
153  return seed_;
154  }
155  void seed(uint32_t s) {
156  seed_ = s;
157  reset();
158  }
159 
160  private:
161  uint32_t seed_;
162  void* rng_;
163  static uint32_t cnt_;
164 };
165 
166 Isaac64::Isaac64(uint32_t seed) {
167  if (cnt_ == 0) {
168  cnt_ = 0xffffffff;
169  }
170  --cnt_;
171  seed_ = seed;
172  if (seed_ == 0) {
173  seed_ = cnt_;
174  }
175  rng_ = nrnisaac_new();
176  reset();
177 }
180 }
181 
182 uint32_t Isaac64::cnt_ = 0;
183 
184 RandomPlay::RandomPlay(Rand* r, double* px) {
185  // printf("RandomPlay\n");
186  r_ = r;
187  px_ = px;
188  random_play_list_->push_back(this);
189  ref();
191  nrn_notify_when_void_freed((void*) r->obj_, this);
192 }
194  // printf("~RandomPlay\n");
195 }
197  // printf("RandomPlay::play\n");
198  *px_ = (*(r_->rand))();
199 }
201  for (auto it = random_play_list_->begin(); it != random_play_list_->end(); ++it) {
202  if (*it == (RandomPlay*) this) {
203  // printf("RandomPlay %p removed from list cnt=%d i=%d %p\n", this, cnt, i);
204  random_play_list_->erase(it);
205  unref_deferred();
206  break;
207  }
208  }
209 }
211  // printf("RandomPlay::update\n");
213  list_remove();
214 }
215 
216 Rand::Rand(unsigned long seed, int size, Object* obj) {
217  // printf("Rand\n");
218  gen = new ACG(seed, size);
219  rand = new Normal(0., 1., gen);
220  type_ = 0;
221  obj_ = obj;
222 }
223 
225  // printf("~Rand\n");
226  delete gen;
227  delete rand;
228 }
229 
230 // constructor for a random number generator based on the RNG class
231 // from the gnu c++ class library
232 // defaults to the ACG generator (see below)
233 
234 // syntax:
235 // a = new Rand([seed],[size])
236 
237 static void* r_cons(Object* obj) {
238  unsigned long seed = 0;
239  int size = 55;
240 
241  if (ifarg(1))
242  seed = long(*getarg(1));
243  if (ifarg(2))
244  size = int(chkarg(2, 7, 98));
245 
246  Rand* r = new Rand(seed, size, obj);
247  return (void*) r;
248 }
249 
250 // destructor -- called when no longer referenced
251 
252 static void r_destruct(void* r) {
253  delete (Rand*) r;
254 }
255 
256 // Use a variant of the Linear Congruential Generator (algorithm M)
257 // described in Knuth, Art of Computer Programming, Vol. III in
258 // combination with a Fibonacci Additive Congruential Generator.
259 // This is a "very high quality" random number generator,
260 // Default size is 55, giving a size of 1244 bytes to the structure
261 // minimum size is 7 (total 100 bytes), maximum size is 98 (total 2440 bytes)
262 // syntax:
263 // r.ACG([seed],[size])
264 
265 static double r_ACG(void* r) {
266  Rand* x = (Rand*) r;
267 
268  unsigned long seed = 0;
269  int size = 55;
270 
271  if (ifarg(1))
272  seed = long(*getarg(1));
273  if (ifarg(2))
274  size = int(chkarg(2, 7, 98));
275 
276  x->rand->generator(new ACG(seed, size));
277  x->type_ = 0;
278  delete x->gen;
279  x->gen = x->rand->generator();
280  return 1.;
281 }
282 
283 // Use a Multiplicative Linear Congruential Generator. Not as high
284 // quality as the ACG, but uses only 8 bytes
285 // syntax:
286 // r.MLCG([seed1],[seed2])
287 
288 static double r_MLCG(void* r) {
289  Rand* x = (Rand*) r;
290 
291  unsigned long seed1 = 0;
292  unsigned long seed2 = 0;
293 
294  if (ifarg(1))
295  seed1 = long(*getarg(1));
296  if (ifarg(2))
297  seed2 = long(*getarg(2));
298 
299  x->rand->generator(new MLCG(seed1, seed2));
300  delete x->gen;
301  x->gen = x->rand->generator();
302  x->type_ = 1;
303  return 1.;
304 }
305 
306 static double r_MCellRan4(void* r) {
307  Rand* x = (Rand*) r;
308 
309  uint32_t seed1 = 0;
310  uint32_t ilow = 0;
311 
312  if (ifarg(1))
313  seed1 = (uint32_t) (chkarg(1, 0., dmaxuint));
314  if (ifarg(2))
315  ilow = (uint32_t) (chkarg(2, 0., dmaxuint));
316  MCellRan4* mcr = new MCellRan4(seed1, ilow);
317  x->rand->generator(mcr);
318  delete x->gen;
319  x->gen = x->rand->generator();
320  x->type_ = 2;
321  return (double) mcr->orig_;
322 }
323 
324 extern "C" long nrn_get_random_sequence(Rand* r) {
325  assert(r->type_ == 2);
326  MCellRan4* mcr = (MCellRan4*) r->gen;
327  return mcr->ihigh_;
328 }
329 
330 extern "C" void nrn_set_random_sequence(Rand* r, long seq) {
331  assert(r->type_ == 2);
332  MCellRan4* mcr = (MCellRan4*) r->gen;
333  mcr->ihigh_ = seq;
334 }
335 
336 extern "C" int nrn_random_isran123(Rand* r, uint32_t* id1, uint32_t* id2, uint32_t* id3) {
337  if (r->type_ == 4) {
338  NrnRandom123* nr = (NrnRandom123*) r->gen;
339  nrnran123_getids3(nr->s_, id1, id2, id3);
340  return 1;
341  }
342  return 0;
343 }
344 
345 static double r_nrnran123(void* r) {
346  Rand* x = (Rand*) r;
347  uint32_t id1 = 0;
348  uint32_t id2 = 0;
349  uint32_t id3 = 0;
350  if (ifarg(1))
351  id1 = (uint32_t) (chkarg(1, 0., dmaxuint));
352  if (ifarg(2))
353  id2 = (uint32_t) (chkarg(2, 0., dmaxuint));
354  if (ifarg(3))
355  id3 = (uint32_t) (chkarg(3, 0., dmaxuint));
356  NrnRandom123* r123 = new NrnRandom123(id1, id2, id3);
357  x->rand->generator(r123);
358  delete x->gen;
359  x->gen = x->rand->generator();
360  x->type_ = 4;
361  return 0.;
362 }
363 
364 static double r_ran123_globalindex(void* r) {
365  if (ifarg(1)) {
366  uint32_t gix = (uint32_t) chkarg(1, 0., 4294967295.); /* 2^32 - 1 */
368  }
369  return (double) nrnran123_get_globalindex();
370 }
371 
372 static double r_sequence(void* r) {
373  Rand* x = (Rand*) r;
374  if (x->type_ != 2 && x->type_ != 4) {
376  "Random.seq() can only be used if the random generator was MCellRan4 or Random123", 0);
377  }
378 
379  if (x->type_ == 4) {
380  uint32_t seq;
381  char which;
382  if (ifarg(1)) {
383  double s = chkarg(1, 0., 17179869183.); /* 2^34 - 1 */
384  seq = (uint32_t) (s / 4.);
385  which = char(s - seq * 4.);
386  NrnRandom123* nr = (NrnRandom123*) x->gen;
387  nrnran123_setseq(nr->s_, seq, which);
388  }
389  nrnran123_getseq(((NrnRandom123*) x->gen)->s_, &seq, &which);
390  return double(seq) * 4. + double(which);
391  }
392 
393  MCellRan4* mcr = (MCellRan4*) x->gen;
394  if (ifarg(1)) {
395  mcr->ihigh_ = (long) (*getarg(1));
396  }
397  return (double) mcr->ihigh_;
398 }
399 
400 int nrn_random123_setseq(Rand* r, uint32_t seq, char which) {
401  if (r->type_ != 4) {
402  return 0;
403  }
404  nrnran123_setseq(((NrnRandom123*) r->gen)->s_, seq, which);
405  return 1;
406 }
407 
408 int nrn_random123_getseq(Rand* r, uint32_t* seq, char* which) {
409  if (r->type_ != 4) {
410  return 0;
411  }
412  nrnran123_getseq(((NrnRandom123*) r->gen)->s_, seq, which);
413  return 1;
414 }
415 
416 static double r_Isaac64(void* r) {
417  Rand* x = (Rand*) r;
418 
419  uint32_t seed1 = 0;
420 
421  if (ifarg(1))
422  seed1 = (uint32_t) (*getarg(1));
423  Isaac64* mcr = new Isaac64(seed1);
424  x->rand->generator(mcr);
425  delete x->gen;
426  x->gen = x->rand->generator();
427  x->type_ = 3;
428  return (double) mcr->seed();
429 }
430 
431 // Pick again from the distribution last used
432 // syntax:
433 // r.repick()
434 static double r_repick(void* r) {
435  Rand* x = (Rand*) r;
436  return (*(x->rand))();
437 }
438 
439 extern "C" double nrn_random_pick(Rand* r) {
440  if (r) {
441  return (*(r->rand))();
442  } else {
443  return .5;
444  }
445 }
446 
447 extern "C" void nrn_random_reset(Rand* r) {
448  if (r) {
449  r->gen->reset();
450  }
451 }
452 
453 extern "C" Rand* nrn_random_arg(int i) {
454  Object* ob = *hoc_objgetarg(i);
455  check_obj_type(ob, "Random");
456  Rand* r = (Rand*) (ob->u.this_pointer);
457  return r;
458 }
459 
460 // uniform random variable over the open interval [low...high)
461 // syntax:
462 // r.uniform(low,high)
463 
464 static double r_uniform(void* r) {
465  Rand* x = (Rand*) r;
466  double a1 = *getarg(1);
467  double a2 = *getarg(2);
468  delete x->rand;
469  x->rand = new Uniform(a1, a2, x->gen);
470  return (*(x->rand))();
471 }
472 
473 // uniform random variable over the closed interval [low...high]
474 // syntax:
475 // r.discunif(low,high)
476 
477 static double r_discunif(void* r) {
478  Rand* x = (Rand*) r;
479  long a1 = long(*getarg(1));
480  long a2 = long(*getarg(2));
481  delete x->rand;
482  x->rand = new DiscreteUniform(a1, a2, x->gen);
483  return (*(x->rand))();
484 }
485 
486 
487 // normal (gaussian) distribution
488 // syntax:
489 // r.normal(mean,variance)
490 
491 static double r_normal(void* r) {
492  Rand* x = (Rand*) r;
493  double a1 = *getarg(1);
494  double a2 = *getarg(2);
495  delete x->rand;
496  x->rand = new Normal(a1, a2, x->gen);
497  return (*(x->rand))();
498 }
499 
500 
501 // logarithmic normal distribution
502 // syntax:
503 // r.lognormal(mean)
504 
505 static double r_lognormal(void* r) {
506  Rand* x = (Rand*) r;
507  double a1 = *getarg(1);
508  double a2 = *getarg(2);
509  delete x->rand;
510  x->rand = new LogNormal(a1, a2, x->gen);
511  return (*(x->rand))();
512 }
513 
514 
515 // poisson distribution
516 // syntax:
517 // r.poisson(mean)
518 
519 static double r_poisson(void* r) {
520  Rand* x = (Rand*) r;
521  double a1 = *getarg(1);
522  delete x->rand;
523  x->rand = new Poisson(a1, x->gen);
524  return (*(x->rand))();
525 }
526 
527 
528 // binomial distribution, which models successfully drawing items from a pool
529 // n is the number items in the pool and p is the probablity of each item
530 // being successfully drawn (n>0, 0<=p<=1)
531 // syntax:
532 // r.binomial(n,p)
533 
534 static double r_binomial(void* r) {
535  Rand* x = (Rand*) r;
536  int a1 = int(chkarg(1, 0, 1e99));
537  double a2 = chkarg(2, 0, 1);
538  delete x->rand;
539  x->rand = new Binomial(a1, a2, x->gen);
540  return (*(x->rand))();
541 }
542 
543 
544 // discrete geometric distribution
545 // Given 0<=mean<=1, returns the number of uniform random samples
546 // that were drawn before the sample was larger than mean (always
547 // greater than 0.
548 // syntax:
549 // r.geometric(mean)
550 
551 static double r_geometric(void* r) {
552  Rand* x = (Rand*) r;
553  double a1 = chkarg(1, 0, 1);
554  delete x->rand;
555  x->rand = new Geometric(a1, x->gen);
556  return (*(x->rand))();
557 }
558 
559 
560 // hypergeometric distribution
561 // syntax:
562 // r.hypergeo(mean,variance)
563 
564 static double r_hypergeo(void* r) {
565  Rand* x = (Rand*) r;
566  double a1 = *getarg(1);
567  double a2 = *getarg(2);
568  delete x->rand;
569  x->rand = new HyperGeometric(a1, a2, x->gen);
570  return (*(x->rand))();
571 }
572 
573 
574 // negative exponential distribution
575 // syntax:
576 // r.negexp(mean)
577 
578 static double r_negexp(void* r) {
579  Rand* x = (Rand*) r;
580  double a1 = *getarg(1);
581  delete x->rand;
582  x->rand = new NegativeExpntl(a1, x->gen);
583  return (*(x->rand))();
584 }
585 
586 
587 // Erlang distribution
588 // syntax:
589 // r.erlang(mean,variance)
590 
591 static double r_erlang(void* r) {
592  Rand* x = (Rand*) r;
593  double a1 = *getarg(1);
594  double a2 = *getarg(2);
595  delete x->rand;
596  x->rand = new Erlang(a1, a2, x->gen);
597  return (*(x->rand))();
598 }
599 
600 
601 // Weibull distribution
602 // syntax:
603 // r.weibull(alpha,beta)
604 
605 static double r_weibull(void* r) {
606  Rand* x = (Rand*) r;
607  double a1 = *getarg(1);
608  double a2 = *getarg(2);
609  delete x->rand;
610  x->rand = new Weibull(a1, a2, x->gen);
611  return (*(x->rand))();
612 }
613 
614 static double r_play(void* r) {
615  new RandomPlay((Rand*) r, hoc_pgetarg(1));
616  return 0.;
617 }
618 
619 extern "C" void nrn_random_play() {
620  for (const auto& rp: *random_play_list_) {
621  rp->play();
622  }
623 }
624 
625 
626 static Member_func r_members[] = {{"ACG", r_ACG},
627  {"MLCG", r_MLCG},
628  {"Isaac64", r_Isaac64},
629  {"MCellRan4", r_MCellRan4},
630  {"Random123", r_nrnran123},
631  {"Random123_globalindex", r_ran123_globalindex},
632  {"seq", r_sequence},
633  {"repick", r_repick},
634  {"uniform", r_uniform},
635  {"discunif", r_discunif},
636  {"normal", r_normal},
637  {"lognormal", r_lognormal},
638  {"binomial", r_binomial},
639  {"poisson", r_poisson},
640  {"geometric", r_geometric},
641  {"hypergeo", r_hypergeo},
642  {"negexp", r_negexp},
643  {"erlang", r_erlang},
644  {"weibull", r_weibull},
645  {"play", r_play},
646  {nullptr, nullptr}};
647 
648 void Random_reg() {
649  class2oc("Random", r_cons, r_destruct, r_members, NULL, NULL, NULL);
651 }
Definition: ACG.h:43
Definition: Erlang.h:26
Definition: Geom.h:26
virtual double asDouble()
Definition: ivocrand.cpp:149
virtual uint32_t asLong()
Definition: ivocrand.cpp:143
virtual ~Isaac64()
Definition: ivocrand.cpp:178
Isaac64(uint32_t seed=0)
Definition: ivocrand.cpp:166
virtual void reset()
Definition: ivocrand.cpp:146
static uint32_t cnt_
Definition: ivocrand.cpp:163
void seed(uint32_t s)
Definition: ivocrand.cpp:155
uint32_t seed_
Definition: ivocrand.cpp:161
uint32_t seed()
Definition: ivocrand.cpp:152
void * rng_
Definition: ivocrand.cpp:162
uint32_t ihigh_
Definition: ivocrand.cpp:117
uint32_t orig_
Definition: ivocrand.cpp:118
static uint32_t cnt_
Definition: ivocrand.cpp:122
virtual void reset()
Definition: ivocrand.cpp:111
virtual uint32_t asLong()
Definition: ivocrand.cpp:108
virtual ~MCellRan4()
Definition: ivocrand.cpp:135
virtual double asDouble()
Definition: ivocrand.cpp:114
uint32_t ilow_
Definition: ivocrand.cpp:119
MCellRan4(uint32_t ihigh=0, uint32_t ilow=0)
Definition: ivocrand.cpp:125
Definition: MLCG.h:31
Definition: Normal.h:26
nrnran123_State * s_
Definition: ivocrand.cpp:87
NrnRandom123(uint32_t id1, uint32_t id2, uint32_t id3=0)
Definition: ivocrand.cpp:89
virtual ~NrnRandom123()
Definition: ivocrand.cpp:92
virtual uint32_t asLong()
Definition: ivocrand.cpp:78
virtual void reset()
Definition: ivocrand.cpp:84
virtual double asDouble()
Definition: ivocrand.cpp:81
Definition: RNG.h:55
virtual void reset()=0
Definition: random1.h:9
~Rand()
Definition: ivocrand.cpp:224
Random * rand
Definition: random1.h:14
int type_
Definition: random1.h:15
Object * obj_
Definition: random1.h:17
RNG * gen
Definition: random1.h:13
Rand(unsigned long seed=0, int size=55, Object *obj=NULL)
Definition: ivocrand.cpp:216
RNG * generator()
Definition: Random.h:50
void play()
Definition: ivocrand.cpp:196
RandomPlay(Rand *, double *)
Definition: ivocrand.cpp:184
virtual ~RandomPlay()
Definition: ivocrand.cpp:193
void list_remove()
Definition: ivocrand.cpp:200
virtual void update(Observable *)
Definition: ivocrand.cpp:210
Rand * r_
Definition: ivocrand.cpp:54
double * px_
Definition: ivocrand.cpp:55
virtual void ref() const
Definition: resource.cpp:47
virtual void unref_deferred() const
Definition: resource.cpp:63
double chkarg(int, double low, double high)
Definition: code2.cpp:638
void hoc_execerror(const char *, const char *)
Definition: hoc.cpp:754
double * hoc_pgetarg(int narg)
Definition: code.cpp:1623
#define assert(ex)
Definition: hocassrt.h:32
#define getarg
Definition: hocdec.h:15
Object ** hoc_objgetarg(int)
Definition: code.cpp:1587
void nrn_notify_when_void_freed(void *p, Observer *ob)
Definition: ivoc.cpp:52
void nrn_notify_when_double_freed(double *p, Observer *ob)
Definition: ivoc.cpp:61
void nrn_notify_pointer_disconnect(Observer *ob)
Definition: ivoc.cpp:70
int ifarg(int)
Definition: code.cpp:1581
#define dmaxuint
Definition: ivocrand.cpp:41
static double r_negexp(void *r)
Definition: ivocrand.cpp:578
void nrn_random_reset(Rand *r)
Definition: ivocrand.cpp:447
int nrn_random123_setseq(Rand *r, uint32_t seq, char which)
Definition: ivocrand.cpp:400
static void * r_cons(Object *obj)
Definition: ivocrand.cpp:237
static double r_poisson(void *r)
Definition: ivocrand.cpp:519
static double r_sequence(void *r)
Definition: ivocrand.cpp:372
static double r_repick(void *r)
Definition: ivocrand.cpp:434
static double r_uniform(void *r)
Definition: ivocrand.cpp:464
static void r_destruct(void *r)
Definition: ivocrand.cpp:252
double nrn_random_pick(Rand *r)
Definition: ivocrand.cpp:439
static double r_ran123_globalindex(void *r)
Definition: ivocrand.cpp:364
static double r_discunif(void *r)
Definition: ivocrand.cpp:477
static double r_MCellRan4(void *r)
Definition: ivocrand.cpp:306
static Member_func r_members[]
Definition: ivocrand.cpp:626
int nrn_random123_getseq(Rand *r, uint32_t *seq, char *which)
Definition: ivocrand.cpp:408
static double r_MLCG(void *r)
Definition: ivocrand.cpp:288
static double r_normal(void *r)
Definition: ivocrand.cpp:491
void nrn_random_play()
Definition: ivocrand.cpp:619
static double r_hypergeo(void *r)
Definition: ivocrand.cpp:564
int nrn_random_isran123(Rand *r, uint32_t *id1, uint32_t *id2, uint32_t *id3)
Definition: ivocrand.cpp:336
static double r_weibull(void *r)
Definition: ivocrand.cpp:605
static RandomPlayList * random_play_list_
Definition: ivocrand.cpp:59
static double r_lognormal(void *r)
Definition: ivocrand.cpp:505
void nrn_set_random_sequence(Rand *r, long seq)
Definition: ivocrand.cpp:330
static double r_play(void *r)
Definition: ivocrand.cpp:614
static double r_erlang(void *r)
Definition: ivocrand.cpp:591
std::vector< RandomPlay * > RandomPlayList
Definition: ivocrand.cpp:58
static double r_ACG(void *r)
Definition: ivocrand.cpp:265
void Random_reg()
Definition: ivocrand.cpp:648
static double r_Isaac64(void *r)
Definition: ivocrand.cpp:416
static double r_nrnran123(void *r)
Definition: ivocrand.cpp:345
long nrn_get_random_sequence(Rand *r)
Definition: ivocrand.cpp:324
Rand * nrn_random_arg(int)
Definition: ivocrand.cpp:453
static double r_binomial(void *r)
Definition: ivocrand.cpp:534
static double r_geometric(void *r)
Definition: ivocrand.cpp:551
uint32_t nrnRan4int(uint32_t *idx1, uint32_t idx2)
Definition: mcran4.cpp:107
uint32_t mcell_iran4(uint32_t *high)
Definition: mcran4.cpp:69
double nrnRan4dbl(uint32_t *idx1, uint32_t idx2)
Definition: mcran4.cpp:162
double mcell_ran4a(uint32_t *high)
Definition: mcran4.cpp:65
#define i
Definition: md1redef.h:12
if(status)
void nrnisaac_delete(void *v)
Definition: nrnisaac.cpp:19
double nrnisaac_dbl_pick(void *v)
Definition: nrnisaac.cpp:27
uint32_t nrnisaac_uint32_pick(void *v)
Definition: nrnisaac.cpp:34
void * nrnisaac_new(void)
Definition: nrnisaac.cpp:12
void nrnisaac_init(void *v, unsigned long int seed)
Definition: nrnisaac.cpp:23
void class2oc(const char *, void *(*cons)(Object *), void(*destruct)(void *), Member_func *, int(*checkpoint)(void **), Member_ret_obj_func *, Member_ret_str_func *)
Definition: hoc_oop.cpp:1560
void nrnran123_setseq(nrnran123_State *s, uint32_t seq, char which)
Definition: nrnran123.cpp:50
void nrnran123_getids3(nrnran123_State *s, uint32_t *id1, uint32_t *id2, uint32_t *id3)
Definition: nrnran123.cpp:65
void nrnran123_set_globalindex(uint32_t gix)
Definition: nrnran123.cpp:19
uint32_t nrnran123_ipick(nrnran123_State *s)
Definition: nrnran123.cpp:71
void nrnran123_getseq(nrnran123_State *s, uint32_t *seq, char *which)
Definition: nrnran123.cpp:45
void nrnran123_deletestream(nrnran123_State *s)
Definition: nrnran123.cpp:41
double nrnran123_dblpick(nrnran123_State *s)
Definition: nrnran123.cpp:85
uint32_t nrnran123_get_globalindex()
Definition: nrnran123.cpp:24
nrnran123_State * nrnran123_newstream3(uint32_t id1, uint32_t id2, uint32_t id3)
Definition: nrnran123.cpp:31
struct Rand Rand
Ideally the prototypes below would take Rand* in place of void*, but this would break several existin...
Definition: nrnrandom.h:14
check_obj_type(o, "SectionList")
#define NULL
Definition: sptree.h:16
Definition: hocdec.h:227
void * this_pointer
Definition: hocdec.h:232
union Object::@39 u