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