Skip to content

Commit 9f4c5de

Browse files
committed
* c/mt19937/mt19937.c (mt19937_init_by_array,init_genrand): Remove unused.
* c/mt19937/mt19937.h: Remove declarations.
1 parent dd1ddbb commit 9f4c5de

File tree

2 files changed

+0
-101
lines changed

2 files changed

+0
-101
lines changed

c/mt19937/mt19937.c

Lines changed: 0 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -15,104 +15,6 @@ void mt19937_seed(mt19937_state *state, uint32_t seed) {
1515
state->pos = RK_STATE_LEN;
1616
}
1717

18-
/* initializes mt[RK_STATE_LEN] with a seed */
19-
static void init_genrand(mt19937_state *state, uint32_t s) {
20-
int mti;
21-
uint32_t *mt = state->key;
22-
23-
mt[0] = s & 0xffffffffUL;
24-
for (mti = 1; mti < RK_STATE_LEN; mti++) {
25-
/*
26-
* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier.
27-
* In the previous versions, MSBs of the seed affect
28-
* only MSBs of the array mt[].
29-
* 2002/01/09 modified by Makoto Matsumoto
30-
*/
31-
/* This code triggers conversions between uint32_t and unsigned long,
32-
which various compilers warn about. */
33-
# pragma GCC diagnostic push
34-
# pragma GCC diagnostic ignored "-Wconversion"
35-
#if defined(__clang__)
36-
# pragma clang diagnostic push
37-
# pragma clang diagnostic ignored "-Wimplicit-int-conversion"
38-
#endif
39-
mt[mti] = (1812433253UL * (mt[mti - 1] ^ (mt[mti - 1] >> 30)) + mti);
40-
# pragma GCC diagnostic pop
41-
#if defined(__clang__)
42-
# pragma clang diagnostic pop
43-
#endif
44-
/* for > 32 bit machines */
45-
mt[mti] &= 0xffffffffUL;
46-
}
47-
state->pos = mti;
48-
return;
49-
}
50-
51-
/*
52-
* initialize by an array with array-length
53-
* init_key is the array for initializing keys
54-
* key_length is its length
55-
*/
56-
void mt19937_init_by_array(mt19937_state *state, uint32_t *init_key,
57-
int key_length) {
58-
/* was signed in the original code. RDH 12/16/2002 */
59-
int i = 1;
60-
int j = 0;
61-
uint32_t *mt = state->key;
62-
int k;
63-
64-
init_genrand(state, 19650218UL);
65-
k = (RK_STATE_LEN > key_length ? RK_STATE_LEN : key_length);
66-
for (; k; k--) {
67-
# pragma GCC diagnostic push
68-
# pragma GCC diagnostic ignored "-Wconversion"
69-
#if defined(__clang__)
70-
# pragma clang diagnostic push
71-
# pragma clang diagnostic ignored "-Wimplicit-int-conversion"
72-
#endif
73-
/* non linear */
74-
mt[i] = (mt[i] ^ ((mt[i - 1] ^ (mt[i - 1] >> 30)) * 1664525UL)) + init_key[j] + j;
75-
# pragma GCC diagnostic pop
76-
#if defined(__clang__)
77-
# pragma clang diagnostic pop
78-
#endif
79-
/* for > 32 bit machines */
80-
mt[i] &= 0xffffffffUL;
81-
i++;
82-
j++;
83-
if (i >= RK_STATE_LEN) {
84-
mt[0] = mt[RK_STATE_LEN - 1];
85-
i = 1;
86-
}
87-
if (j >= key_length) {
88-
j = 0;
89-
}
90-
}
91-
for (k = RK_STATE_LEN - 1; k; k--) {
92-
/* This code triggers conversions between uint32_t and unsigned long,
93-
which various compilers warn about. */
94-
# pragma GCC diagnostic push
95-
# pragma GCC diagnostic ignored "-Wconversion"
96-
#if defined(__clang__)
97-
# pragma clang diagnostic push
98-
# pragma clang diagnostic ignored "-Wimplicit-int-conversion"
99-
#endif
100-
mt[i] = (mt[i] ^ ((mt[i - 1] ^ (mt[i - 1] >> 30)) * 1566083941UL)) - i; /* non linear */
101-
# pragma GCC diagnostic pop
102-
#if defined(__clang__)
103-
# pragma clang diagnostic pop
104-
#endif
105-
mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */
106-
i++;
107-
if (i >= RK_STATE_LEN) {
108-
mt[0] = mt[RK_STATE_LEN - 1];
109-
i = 1;
110-
}
111-
}
112-
113-
mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */
114-
}
115-
11618
void mt19937_gen(mt19937_state *state) {
11719
uint32_t y;
11820
int i;

c/mt19937/mt19937.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ static inline uint32_t mt19937_next(mt19937_state *state) {
4343
return y;
4444
}
4545

46-
extern void mt19937_init_by_array(mt19937_state *state, uint32_t *init_key,
47-
int key_length);
48-
4946
static inline uint64_t mt19937_next64(mt19937_state *state) {
5047
return (uint64_t)mt19937_next(state) << 32 | mt19937_next(state);
5148
}

0 commit comments

Comments
 (0)