Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Nov 20, 2020. It is now read-only.
forked from carvalho/numlua
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrng.h
More file actions
Latest commit
56 lines (49 loc) · 1.96 KB
/
Copy pathrng.h
File metadata and controls
56 lines (49 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* {=================================================================
*
* rng.h
* Random number generator (RNG) library for Lua [header file]
* Luis Carvalho (lexcarvalho@gmail.com)
* See Copyright Notice in numlua.h
*
* ==================================================================} */
#ifndefrng_h
#definerng_h
#include<lua.h>
#include"numlua.h"
/* Uniform deviates are generated by Mersenne Twister method,
* algorithm mt19937 by Makoto Matsumoto and Takuji Nishimura.
* Check mt.c for details. */
/* Struct to hold state vector and current position */
#defineRNG_MAXSTATES (624) /* _N_ in mt19937ar.c */
typedefstruct {
unsigned longv[RNG_MAXSTATES]; /* the array for the state vector */
inti; /* i==N+1 means v[N] is not initialized */
} nl_RNG;
#defineRNG_SEED (5489UL) /* default initial seed in mt199937ar.c */
voidinit_genrand(nl_RNG*o, unsigned longs);
voidinit_by_array(nl_RNG*o, unsigned longinit_key[], intkey_length);
unsigned longgenrand_int32(nl_RNG*o);
longgenrand_int31(nl_RNG*o);
doublegenrand_real1(nl_RNG*o);
doublegenrand_real2(nl_RNG*o);
doublegenrand_real3(nl_RNG*o);
doublegenrand_res53(nl_RNG*o);
/* All other deviates are computed from an adapted ranlib.c from Netlib */
#defineranf(o) genrand_real3(o)
#defineignlgi(o) genrand_int31(o)
doublegenbet(nl_RNG*o,doubleaa,doublebb);
doublegenchi(nl_RNG*o,doubledf);
doublegenexp(nl_RNG*o,doubleav);
doublegenf(nl_RNG*o,doubledfn,doubledfd);
doublegengam(nl_RNG*o,doublea,doubler);
voidgenmul(nl_RNG*o,longn,double*p,longncat,long*ix);
doublegennch(nl_RNG*o,doubledf,doublexnonc);
doublegennf(nl_RNG*o,doubledfn,doubledfd,doublexnonc);
doublegennor(nl_RNG*o,doubleav,doublesd);
voidgenprm(nl_RNG*o,long*iarray,intlarray);
doublegenunf(nl_RNG*o,doublelow,doublehigh);
longignbin(nl_RNG*o,longn,doublepp);
longignnbn(nl_RNG*o,longn,doublep);
longignpoi(nl_RNG*o,doublemu);
longignuin(nl_RNG*o,longlow,longhigh);
#endif