1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.rng.simple;
18
19 import java.util.Arrays;
20 import java.util.List;
21 import java.util.ArrayList;
22 import java.util.Collections;
23
24
25
26
27
28
29
30
31
32
33 public final class ProvidersList {
34
35 private static final List<Data> LIST = new ArrayList<>();
36
37 private static final List<Data> LIST32 = new ArrayList<>();
38
39 private static final List<Data> LIST64 = new ArrayList<>();
40
41 static {
42 try {
43
44 add(LIST32, RandomSource.JDK, -122333444455555L);
45 add(LIST32, RandomSource.MT, new int[] {-123, -234, -345});
46 add(LIST32, RandomSource.WELL_512_A, new int[] {-23, -34, -45});
47 add(LIST32, RandomSource.WELL_1024_A, new int[] {-1234, -2345, -3456});
48 add(LIST32, RandomSource.WELL_19937_A, new int[] {-2123, -3234, -4345});
49 add(LIST32, RandomSource.WELL_19937_C, new int[] {-123, -234, -345, -456});
50 add(LIST32, RandomSource.WELL_44497_A, new int[] {-12345, -23456, -34567});
51 add(LIST32, RandomSource.WELL_44497_B, new int[] {123, 234, 345});
52 add(LIST32, RandomSource.ISAAC, new int[] {123, -234, 345, -456});
53 add(LIST32, RandomSource.MWC_256, new int[] {12, -1234, -3456, 45678});
54 add(LIST32, RandomSource.KISS, new int[] {12, 1234, 23456, 345678});
55 add(LIST32, RandomSource.XO_RO_SHI_RO_64_S, new int[] {42, 12345});
56 add(LIST32, RandomSource.XO_RO_SHI_RO_64_SS, new int[] {78942, 134});
57 add(LIST32, RandomSource.XO_SHI_RO_128_PLUS, new int[] {565642, 1234, 4534});
58 add(LIST32, RandomSource.XO_SHI_RO_128_SS, new int[] {89, 1234, 6787});
59 add(LIST32, RandomSource.PCG_XSH_RR_32, new long[] {1738L, 1234L});
60 add(LIST32, RandomSource.PCG_XSH_RS_32, new long[] {259L, 2861L});
61 add(LIST32, RandomSource.PCG_MCG_XSH_RS_32, 9678L);
62 add(LIST32, RandomSource.PCG_MCG_XSH_RR_32, 2578291L);
63
64
65 add(LIST32, RandomSource.MSWS, new long[] {687233648L, 678656564562300L, 0xb5ad4eceda1ce2a9L});
66 add(LIST32, RandomSource.SFC_32, new int[] {-23574234, 7654343});
67 add(LIST32, RandomSource.XO_SHI_RO_128_PP, new int[] {8796823, -3244890, -263842});
68 add(LIST32, RandomSource.PCG_XSH_RR_32_OS, 72346247L);
69 add(LIST32, RandomSource.PCG_XSH_RS_32_OS, -5340832872354L);
70 add(LIST32, RandomSource.L32_X64_MIX, new int[] {2134678128, -162788128});
71
72
73
74 add(LIST64, RandomSource.SPLIT_MIX_64, -988777666655555L);
75 add(LIST64, RandomSource.XOR_SHIFT_1024_S, new long[] {123456L, 234567L, -345678L});
76 add(LIST64, RandomSource.XOR_SHIFT_1024_S_PHI, new long[] {-234567L, -345678L, 3456789L});
77 add(LIST64, RandomSource.TWO_CMRES, 55443322);
78 add(LIST64, RandomSource.TWO_CMRES_SELECT, -987654321, 5, 8);
79 add(LIST64, RandomSource.MT_64, new long[] {1234567L, 2345678L, -3456789L});
80 add(LIST64, RandomSource.XO_RO_SHI_RO_128_PLUS, new long[] {55646L, -456659L, 565656L});
81 add(LIST64, RandomSource.XO_RO_SHI_RO_128_SS, new long[] {45655L, 5454544L, 4564659L});
82 add(LIST64, RandomSource.XO_SHI_RO_256_PLUS, new long[] {11222L, -568989L, -456789L});
83 add(LIST64, RandomSource.XO_SHI_RO_256_SS, new long[] {98765L, -2345678L, -3456789L});
84 add(LIST64, RandomSource.XO_SHI_RO_512_PLUS, new long[] {89932L, -545669L, 4564689L});
85 add(LIST64, RandomSource.XO_SHI_RO_512_SS, new long[] {123L, -654654L, 45646789L});
86 add(LIST64, RandomSource.PCG_RXS_M_XS_64, new long[] {42088L, 69271L});
87 add(LIST64, RandomSource.SFC_64, new long[] {-2357423478979842L, 76543434515L});
88 add(LIST64, RandomSource.XO_RO_SHI_RO_128_PP, new long[] {789741321465L, -461321684612L, -12301654794L});
89 add(LIST64, RandomSource.XO_SHI_RO_256_PP, new long[] {2374243L, -8097397345383L, -223479293943L});
90 add(LIST64, RandomSource.XO_SHI_RO_512_PP, new long[] {-1210684761321465L, -485132198745L, 89942134798523L});
91 add(LIST64, RandomSource.XO_RO_SHI_RO_1024_PP, new long[] {236424345654L, 781544546164721L, -85235476312346L});
92 add(LIST64, RandomSource.XO_RO_SHI_RO_1024_S, new long[] {-1574314L, 7879874453221215L, -7894343883216L});
93 add(LIST64, RandomSource.XO_RO_SHI_RO_1024_SS, new long[] {-41514541234654321L, -12146412316546L, 7984134134L});
94 add(LIST64, RandomSource.PCG_RXS_M_XS_64_OS, -34657834534L);
95 add(LIST64, RandomSource.L64_X128_SS, new long[] {-2379479823783L, -235642384324L, 123678172804389L});
96 add(LIST64, RandomSource.L64_X128_MIX, new long[] {-9723846672394L, 623748567398002L, -23678792345897934L});
97 add(LIST64, RandomSource.L64_X256_MIX, new long[] {236784568279L, 237894579279L, -2378945793L});
98 add(LIST64, RandomSource.L64_X1024_MIX, new long[] {279834579232345L, -2374689578237L, -2347895789327L});
99 add(LIST64, RandomSource.L128_X128_MIX, new long[] {236748567823789L, 237485792375L, 2374895789324L});
100 add(LIST64, RandomSource.L128_X256_MIX, new long[] {-829345782324L, -92304897238673245L, 28974785792345L});
101 add(LIST64, RandomSource.L128_X1024_MIX, new long[] {-6563745678920234L, 7348578274523L, 234523455234L});
102
103
104
105
106 LIST.addAll(LIST32);
107 LIST.addAll(LIST64);
108 } catch (final Exception e) {
109
110 System.err.println("Unexpected exception while creating the list of generators: " + e);
111 e.printStackTrace(System.err);
112
113 throw new RuntimeException(e);
114 }
115 }
116
117
118
119
120 private ProvidersList() {}
121
122
123
124
125
126 private static void add(List<Data> list,
127 RandomSource source,
128 Object... data) {
129 final RandomSource rng = source;
130 final Object seed = data.length > 0 ? data[0] : null;
131 final Object[] args = data.length > 1 ? Arrays.copyOfRange(data, 1, data.length) : null;
132
133 list.add(new Data(rng, seed, args));
134 }
135
136
137
138
139
140
141
142 public static Iterable<Data> list() {
143 return Collections.unmodifiableList(LIST);
144 }
145
146
147
148
149
150
151
152 public static Iterable<Data> list32() {
153 return Collections.unmodifiableList(LIST32);
154 }
155
156
157
158
159
160
161
162 public static Iterable<Data> list64() {
163 return Collections.unmodifiableList(LIST64);
164 }
165
166
167
168
169
170 public static class Data {
171
172 private final RandomSource source;
173
174 private final Object seed;
175
176 private final Object[] args;
177
178
179
180
181
182
183 public Data(RandomSource source,
184 Object seed,
185 Object[] args) {
186 this.source = source;
187 this.seed = seed;
188 this.args = args;
189 }
190
191
192
193
194
195
196 public RandomSource getSource() {
197 return source;
198 }
199
200
201
202
203
204
205 public Object getSeed() {
206 return seed;
207 }
208
209
210
211
212
213
214 public Object[] getArgs() {
215 return args == null ? null : Arrays.copyOf(args, args.length);
216 }
217
218 @Override
219 public String toString() {
220 return source.toString() + " seed=" + seed + " args=" + Arrays.toString(args);
221 }
222 }
223 }