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