1 | /* |
---|
2 | A C-program for MT19937, with initialization improved 2002/1/26. |
---|
3 | Coded by Takuji Nishimura and Makoto Matsumoto. |
---|
4 | |
---|
5 | Before using, initialize the state by using init_genrand(seed) |
---|
6 | or init_by_array(init_key, key_length). |
---|
7 | |
---|
8 | Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, |
---|
9 | All rights reserved. |
---|
10 | |
---|
11 | Redistribution and use in source and binary forms, with or without |
---|
12 | modification, are permitted provided that the following conditions |
---|
13 | are met: |
---|
14 | |
---|
15 | 1. Redistributions of source code must retain the above copyright |
---|
16 | notice, this list of conditions and the following disclaimer. |
---|
17 | |
---|
18 | 2. Redistributions in binary form must reproduce the above copyright |
---|
19 | notice, this list of conditions and the following disclaimer in the |
---|
20 | documentation and/or other materials provided with the distribution. |
---|
21 | |
---|
22 | 3. The names of its contributors may not be used to endorse or promote |
---|
23 | products derived from this software without specific prior written |
---|
24 | permission. |
---|
25 | |
---|
26 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
---|
27 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
---|
28 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
---|
29 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
---|
30 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
---|
31 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
---|
32 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
---|
33 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
---|
34 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
---|
35 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
---|
36 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
37 | |
---|
38 | |
---|
39 | Any feedback is very welcome. |
---|
40 | http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html |
---|
41 | email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space) |
---|
42 | */ |
---|
43 | /* initializes mt[N] with a seed */ |
---|
44 | void init_genrand(unsigned long s); |
---|
45 | |
---|
46 | /* initialize by an array with array-length */ |
---|
47 | /* init_key is the array for initializing keys */ |
---|
48 | /* key_length is its length */ |
---|
49 | /* slight change for C++, 2004/2/26 */ |
---|
50 | void init_by_array(unsigned long init_key[], int key_length); |
---|
51 | |
---|
52 | |
---|
53 | /* generates a random number on [0,0xffffffff]-interval */ |
---|
54 | unsigned long genrand_int32(void); |
---|
55 | |
---|
56 | /* generates a random number on [0,0x7fffffff]-interval */ |
---|
57 | long genrand_int31(void); |
---|
58 | |
---|
59 | /* generates a random number on [0,1]-real-interval */ |
---|
60 | double genrand_real1(void); |
---|
61 | |
---|
62 | /* generates a random number on [0,1)-real-interval */ |
---|
63 | double genrand_real2(void); |
---|
64 | |
---|
65 | /* generates a random number on (0,1)-real-interval */ |
---|
66 | double genrand_real3(void); |
---|
67 | |
---|
68 | /* generates a random number on [0,1) with 53-bit resolution*/ |
---|
69 | double genrand_res53(void); |
---|
70 | |
---|
71 | |
---|
72 | /* These real versions are due to Isaku Wada, 2002/01/09 added */ |
---|
73 | |
---|
74 | int test_mt19937(void); |
---|