Debian Codegraph @

external/gsl/gsl_rng__tt.c

raw symbols SCIP
1 /* rng/tt.c
2 *
3 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 James Theiler, Brian Gough
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or (at
8 * your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20 #include "gsl__config.h"cxx . . $ `<file>/external/gsl/gsl__config.h`/
21 #include <stdlib.h>
22 #include "gsl_rng.h"cxx . . $ `<file>/external/gsl/gsl_rng.h`/
23
24 /* This is the TT800 twisted GSFR generator for 32 bit integers. It
25 has been superceded by MT19937 (mt.c). The period is 2^800.
26
27 This implementation is based on tt800.c, July 8th 1996 version by
28 M. Matsumoto, email: [email protected]
29
30 From: Makoto Matsumoto and Yoshiharu Kurita, "Twisted GFSR
31 Generators II", ACM Transactions on Modelling and Computer
32 Simulation, Vol. 4, No. 3, 1994, pages 254-266. */
33
34 static inline unsigned long int tt_getcxx . . $ tt_get(751e5d26f8574c32). (void *vstate);
35 static double tt_get_doublecxx . . $ tt_get_double(a405b17f82753acc). (void *vstate);
36 static void tt_setcxx . . $ tt_set(5500c4293b1bbef0). (void *state, unsigned long int s);
37
38 #define Ncxx . . $ `external/gsl/gsl_rng__tt.c:38:9`! 25
39 #define Mcxx . . $ `external/gsl/gsl_rng__tt.c:39:9`! 7
40
41 typedef structcxx . . $ $anonymous_type_dc717bdbec4af4d7_0#
42 {
43 int ncxx . . $ $anonymous_type_dc717bdbec4af4d7_0#n.;
44 unsigned long int xcxx . . $ $anonymous_type_dc717bdbec4af4d7_0#x.[Ncxx . . $ `external/gsl/gsl_rng__tt.c:38:9`!];
45 }
46 tt_state_tcxx . . $ tt_state_t#;
47
48 static inline unsigned long int
49 tt_getcxx . . $ tt_get(751e5d26f8574c32). (void *vstate)
50 {
51 tt_state_tcxx . . $ tt_state_t# *state = (tt_state_tcxx . . $ tt_state_t# *) vstate;
52
53 /* this is the magic vector, a */
54
55 const unsigned long mag01[2] =
56 {0x00000000, 0x8ebfd028UL};
57 unsigned long int y;
58 unsigned long int *const x = state->xcxx . . $ $anonymous_type_dc717bdbec4af4d7_0#x.;
59 int n = state->ncxx . . $ $anonymous_type_dc717bdbec4af4d7_0#n.;
60
61 if (n >= Ncxx . . $ `external/gsl/gsl_rng__tt.c:38:9`!)
62 {
63 int i;
64 for (i = 0; i < Ncxx . . $ `external/gsl/gsl_rng__tt.c:38:9`! - Mcxx . . $ `external/gsl/gsl_rng__tt.c:39:9`!; i++)
65 {
66 x[i] = x[i + Mcxx . . $ `external/gsl/gsl_rng__tt.c:39:9`!] ^ (x[i] >> 1) ^ mag01[x[i] % 2];
67 }
68 for (; i < Ncxx . . $ `external/gsl/gsl_rng__tt.c:38:9`!; i++)
69 {
70 x[i] = x[i + (Mcxx . . $ `external/gsl/gsl_rng__tt.c:39:9`! - Ncxx . . $ `external/gsl/gsl_rng__tt.c:38:9`!)] ^ (x[i] >> 1) ^ mag01[x[i] % 2];
71 };
72 n = 0;
73 }
74
75 y = x[n];
76 y ^= (y << 7) & 0x2b5b2500UL; /* s and b, magic vectors */
77 y ^= (y << 15) & 0xdb8b0000UL; /* t and c, magic vectors */
78 y &= 0xffffffffUL; /* you may delete this line if word size = 32 */
79
80 /* The following line was added by Makoto Matsumoto in the 1996
81 version to improve lower bit's correlation. Delete this line
82 to use the code published in 1994. */
83
84 y ^= (y >> 16); /* added to the 1994 version */
85
86 state->ncxx . . $ $anonymous_type_dc717bdbec4af4d7_0#n. = n + 1;
87
88 return y;
89 }
90
91 static double
92 tt_get_doublecxx . . $ tt_get_double(a405b17f82753acc). (void * vstate)
93 {
94 return tt_getcxx . . $ tt_get(751e5d26f8574c32). (vstate) / 4294967296.0 ;
95 }
96
97 static void
98 tt_setcxx . . $ tt_set(5500c4293b1bbef0). (void *vstate, unsigned long int s)
99 {
100 tt_state_tcxx . . $ tt_state_t# *state = (tt_state_tcxx . . $ tt_state_t# *) vstate;
101
102 const tt_state_tcxx . . $ tt_state_t# init_state =
103 {0,
104 {0x95f24dabUL, 0x0b685215UL, 0xe76ccae7UL,
105 0xaf3ec239UL, 0x715fad23UL, 0x24a590adUL,
106 0x69e4b5efUL, 0xbf456141UL, 0x96bc1b7bUL,
107 0xa7bdf825UL, 0xc1de75b7UL, 0x8858a9c9UL,
108 0x2da87693UL, 0xb657f9ddUL, 0xffdc8a9fUL,
109 0x8121da71UL, 0x8b823ecbUL, 0x885d05f5UL,
110 0x4e20cd47UL, 0x5a9ad5d9UL, 0x512c0c03UL,
111 0xea857ccdUL, 0x4cc1d30fUL, 0x8891a8a1UL,
112 0xa6b7aadbUL}};
113
114
115 if (s == 0) /* default seed is given explicitly in the original code */
116 {
117 *state = init_state;
118 }
119 else
120 {
121 int i;
122
123 state->ncxx . . $ $anonymous_type_dc717bdbec4af4d7_0#n. = 0;
124
125 state->xcxx . . $ $anonymous_type_dc717bdbec4af4d7_0#x.[0] = s & 0xffffffffUL;
126
127 for (i = 1; i < Ncxx . . $ `external/gsl/gsl_rng__tt.c:38:9`!; i++)
128 state->xcxx . . $ $anonymous_type_dc717bdbec4af4d7_0#x.[i] = (69069 * state->xcxx . . $ $anonymous_type_dc717bdbec4af4d7_0#x.[i - 1]) & 0xffffffffUL;
129 }
130
131 return;
132 }
133
134 static const gsl_rng_typecxx . . $ gsl_rng_type# tt_typecxx . . $ tt_type. =
135 {"tt800", /* name */
136 0xffffffffUL, /* RAND_MAX */
137 0, /* RAND_MIN */
138 sizeof (tt_state_tcxx . . $ tt_state_t#),
139 &tt_setcxx . . $ tt_set(5500c4293b1bbef0).,
140 &tt_getcxx . . $ tt_get(751e5d26f8574c32).,
141 &tt_get_doublecxx . . $ tt_get_double(a405b17f82753acc).};
142
143 const gsl_rng_typecxx . . $ gsl_rng_type# *gsl_rng_tt800cxx . . $ gsl_rng_tt800. = &tt_typecxx . . $ tt_type.;