5742
|
1 /* |
|
2 A C-program for MT19937, with initialization improved 2002/2/10. |
|
3 Coded by Takuji Nishimura and Makoto Matsumoto. |
|
4 This is a faster version by taking Shawn Cokus's optimization, |
|
5 Matthe Bellew's simplification, Isaku Wada's real version. |
|
6 David Bateman added normal and exponential distributions following |
|
7 Marsaglia and Tang's Ziggurat algorithm. |
|
8 |
|
9 Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, |
|
10 Copyright (C) 2004, David Bateman |
|
11 All rights reserved. |
|
12 |
|
13 Redistribution and use in source and binary forms, with or without |
|
14 modification, are permitted provided that the following conditions |
|
15 are met: |
|
16 |
|
17 1. Redistributions of source code must retain the above copyright |
|
18 notice, this list of conditions and the following disclaimer. |
|
19 |
|
20 2. Redistributions in binary form must reproduce the above copyright |
|
21 notice, this list of conditions and the following disclaimer in the |
|
22 documentation and/or other materials provided with the distribution. |
|
23 |
|
24 3. The names of its contributors may not be used to endorse or promote |
|
25 products derived from this software without specific prior written |
|
26 permission. |
|
27 |
|
28 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
29 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
30 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
31 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER |
|
32 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
|
33 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|
34 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
|
35 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
|
36 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
37 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
|
38 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
39 |
|
40 */ |
|
41 |
|
42 #ifndef _RANDMTZIG_H |
|
43 #define _RANDMTZIG_H |
|
44 |
|
45 #include "oct-types.h" |
|
46 |
|
47 #define MT_N 624 |
|
48 |
|
49 #ifdef __cplusplus |
|
50 extern "C" { |
|
51 #endif |
|
52 |
|
53 /* === Mersenne Twister === */ |
|
54 extern void oct_init_by_int (uint32_t s); |
|
55 extern void oct_init_by_array (uint32_t init_key[], int key_length); |
|
56 extern void oct_init_by_entropy (void); |
|
57 extern void oct_set_state (uint32_t save[]); |
|
58 extern void oct_get_state (uint32_t save[]); |
|
59 |
|
60 /* === Array generators === */ |
|
61 extern double oct_randu (void); |
|
62 extern double oct_randn (void); |
|
63 extern double oct_rande (void); |
|
64 |
|
65 /* === Array generators === */ |
|
66 extern void oct_fill_randu (octave_idx_type n, double *p); |
|
67 extern void oct_fill_randn (octave_idx_type n, double *p); |
|
68 extern void oct_fill_rande (octave_idx_type n, double *p); |
|
69 |
|
70 #ifdef __cplusplus |
|
71 } |
|
72 #endif |
|
73 #endif |
|
74 |
|
75 /* |
|
76 ;;; Local Variables: *** |
|
77 ;;; mode: C *** |
|
78 ;;; End: *** |
|
79 */ |
|
80 |