mbed I/F binding for mruby
Dependents: mruby_mbed_web mirb_mbed
mbed-mruby
How to use
Class
mrbgems/mruby-random/mt19937ar.h@0:158c61bb030f, 2015-03-25 (annotated)
- Committer:
- mzta
- Date:
- Wed Mar 25 17:36:16 2015 +0000
- Revision:
- 0:158c61bb030f
mirb_mbed initial commit;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mzta | 0:158c61bb030f | 1 | /* |
mzta | 0:158c61bb030f | 2 | ** mt19937ar.h - MT Random functions |
mzta | 0:158c61bb030f | 3 | ** |
mzta | 0:158c61bb030f | 4 | ** See Copyright Notice in mruby.h |
mzta | 0:158c61bb030f | 5 | */ |
mzta | 0:158c61bb030f | 6 | |
mzta | 0:158c61bb030f | 7 | #define N 624 |
mzta | 0:158c61bb030f | 8 | |
mzta | 0:158c61bb030f | 9 | typedef struct { |
mzta | 0:158c61bb030f | 10 | unsigned long mt[N]; |
mzta | 0:158c61bb030f | 11 | int mti; |
mzta | 0:158c61bb030f | 12 | union { |
mzta | 0:158c61bb030f | 13 | unsigned long int_; |
mzta | 0:158c61bb030f | 14 | double double_; |
mzta | 0:158c61bb030f | 15 | } gen; |
mzta | 0:158c61bb030f | 16 | |
mzta | 0:158c61bb030f | 17 | mrb_int seed; |
mzta | 0:158c61bb030f | 18 | mrb_bool has_seed : 1; |
mzta | 0:158c61bb030f | 19 | } mt_state; |
mzta | 0:158c61bb030f | 20 | |
mzta | 0:158c61bb030f | 21 | void mrb_random_init_genrand(mt_state *, unsigned long); |
mzta | 0:158c61bb030f | 22 | unsigned long mrb_random_genrand_int32(mt_state *); |
mzta | 0:158c61bb030f | 23 | double mrb_random_genrand_real1(mt_state *t); |
mzta | 0:158c61bb030f | 24 | |
mzta | 0:158c61bb030f | 25 | /* initializes mt[N] with a seed */ |
mzta | 0:158c61bb030f | 26 | void init_genrand(unsigned long s); |
mzta | 0:158c61bb030f | 27 | |
mzta | 0:158c61bb030f | 28 | /* initialize by an array with array-length */ |
mzta | 0:158c61bb030f | 29 | /* init_key is the array for initializing keys */ |
mzta | 0:158c61bb030f | 30 | /* key_length is its length */ |
mzta | 0:158c61bb030f | 31 | /* slight change for C++, 2004/2/26 */ |
mzta | 0:158c61bb030f | 32 | void init_by_array(unsigned long init_key[], int key_length); |
mzta | 0:158c61bb030f | 33 | |
mzta | 0:158c61bb030f | 34 | /* generates a random number on [0,0xffffffff]-interval */ |
mzta | 0:158c61bb030f | 35 | unsigned long genrand_int32(void); |
mzta | 0:158c61bb030f | 36 | |
mzta | 0:158c61bb030f | 37 | /* generates a random number on [0,0x7fffffff]-interval */ |
mzta | 0:158c61bb030f | 38 | long genrand_int31(void); |
mzta | 0:158c61bb030f | 39 | |
mzta | 0:158c61bb030f | 40 | /* These real versions are due to Isaku Wada, 2002/01/09 added */ |
mzta | 0:158c61bb030f | 41 | /* generates a random number on [0,1]-real-interval */ |
mzta | 0:158c61bb030f | 42 | double genrand_real1(void); |
mzta | 0:158c61bb030f | 43 | |
mzta | 0:158c61bb030f | 44 | /* generates a random number on [0,1)-real-interval */ |
mzta | 0:158c61bb030f | 45 | double genrand_real2(void); |
mzta | 0:158c61bb030f | 46 | |
mzta | 0:158c61bb030f | 47 | /* generates a random number on (0,1)-real-interval */ |
mzta | 0:158c61bb030f | 48 | double genrand_real3(void); |
mzta | 0:158c61bb030f | 49 | |
mzta | 0:158c61bb030f | 50 | /* generates a random number on [0,1) with 53-bit resolution*/ |
mzta | 0:158c61bb030f | 51 | double genrand_res53(void); |
mzta | 0:158c61bb030f | 52 |