1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.rng.core;
18
19 import java.util.List;
20 import java.util.ArrayList;
21 import java.util.Collections;
22 import java.security.SecureRandom;
23
24 import org.apache.commons.rng.core.source32.JDKRandom;
25 import org.apache.commons.rng.core.source32.JenkinsSmallFast32;
26 import org.apache.commons.rng.core.source32.Well512a;
27 import org.apache.commons.rng.core.source32.XoRoShiRo64Star;
28 import org.apache.commons.rng.core.source32.XoRoShiRo64StarStar;
29 import org.apache.commons.rng.core.source32.XoShiRo128Plus;
30 import org.apache.commons.rng.core.source32.XoShiRo128PlusPlus;
31 import org.apache.commons.rng.core.source32.XoShiRo128StarStar;
32 import org.apache.commons.rng.core.source32.Well1024a;
33 import org.apache.commons.rng.core.source32.Well19937a;
34 import org.apache.commons.rng.core.source32.Well19937c;
35 import org.apache.commons.rng.core.source32.Well44497a;
36 import org.apache.commons.rng.core.source32.Well44497b;
37 import org.apache.commons.rng.core.source32.ISAACRandom;
38 import org.apache.commons.rng.core.source32.MersenneTwister;
39 import org.apache.commons.rng.core.source32.MiddleSquareWeylSequence;
40 import org.apache.commons.rng.core.source32.MultiplyWithCarry256;
41 import org.apache.commons.rng.core.source32.KISSRandom;
42 import org.apache.commons.rng.core.source32.PcgXshRr32;
43 import org.apache.commons.rng.core.source32.PcgXshRs32;
44 import org.apache.commons.rng.core.source32.DotyHumphreySmallFastCounting32;
45 import org.apache.commons.rng.core.source32.PcgMcgXshRr32;
46 import org.apache.commons.rng.core.source32.PcgMcgXshRs32;
47 import org.apache.commons.rng.core.source64.SplitMix64;
48 import org.apache.commons.rng.core.source64.XorShift1024Star;
49 import org.apache.commons.rng.core.source64.XorShift1024StarPhi;
50 import org.apache.commons.rng.core.source64.TwoCmres;
51 import org.apache.commons.rng.core.source64.XoRoShiRo1024PlusPlus;
52 import org.apache.commons.rng.core.source64.XoRoShiRo1024Star;
53 import org.apache.commons.rng.core.source64.XoRoShiRo1024StarStar;
54 import org.apache.commons.rng.core.source64.XoRoShiRo128Plus;
55 import org.apache.commons.rng.core.source64.XoRoShiRo128PlusPlus;
56 import org.apache.commons.rng.core.source64.XoRoShiRo128StarStar;
57 import org.apache.commons.rng.core.source64.XoShiRo256Plus;
58 import org.apache.commons.rng.core.source64.XoShiRo256PlusPlus;
59 import org.apache.commons.rng.core.source64.XoShiRo256StarStar;
60 import org.apache.commons.rng.core.source64.XoShiRo512Plus;
61 import org.apache.commons.rng.core.source64.XoShiRo512PlusPlus;
62 import org.apache.commons.rng.core.source64.XoShiRo512StarStar;
63 import org.apache.commons.rng.core.source64.JenkinsSmallFast64;
64 import org.apache.commons.rng.core.source64.MersenneTwister64;
65 import org.apache.commons.rng.core.source64.PcgRxsMXs64;
66 import org.apache.commons.rng.core.source64.DotyHumphreySmallFastCounting64;
67 import org.apache.commons.rng.JumpableUniformRandomProvider;
68 import org.apache.commons.rng.RestorableUniformRandomProvider;
69
70
71
72
73
74
75
76
77
78
79 public final class ProvidersList {
80
81 private static final List<RestorableUniformRandomProvider[]> LIST =
82 new ArrayList<RestorableUniformRandomProvider[]>();
83
84 private static final List<RestorableUniformRandomProvider[]> LIST32 =
85 new ArrayList<RestorableUniformRandomProvider[]>();
86
87 private static final List<RestorableUniformRandomProvider[]> LIST64 =
88 new ArrayList<RestorableUniformRandomProvider[]>();
89
90 private static final List<JumpableUniformRandomProvider[]> LIST_JUMP =
91 new ArrayList<JumpableUniformRandomProvider[]>();
92
93 static {
94
95 final SecureRandom g = new SecureRandom();
96
97 try {
98
99 add(LIST32, new JDKRandom(g.nextLong()));
100 add(LIST32, new MersenneTwister(new int[] {g.nextInt(), g.nextInt(), g.nextInt()}));
101 add(LIST32, new Well512a(new int[] {g.nextInt(), g.nextInt(), g.nextInt()}));
102 add(LIST32, new Well1024a(new int[] {g.nextInt(), g.nextInt(), g.nextInt()}));
103 add(LIST32, new Well19937a(new int[] {g.nextInt(), g.nextInt(), g.nextInt()}));
104 add(LIST32, new Well19937c(new int[] {g.nextInt(), g.nextInt(), g.nextInt()}));
105 add(LIST32, new Well44497a(new int[] {g.nextInt(), g.nextInt(), g.nextInt()}));
106 add(LIST32, new Well44497b(new int[] {g.nextInt(), g.nextInt(), g.nextInt()}));
107 add(LIST32, new ISAACRandom(new int[] {g.nextInt(), g.nextInt(), g.nextInt()}));
108 add(LIST32, new MultiplyWithCarry256(new int[] {g.nextInt(), g.nextInt(), g.nextInt()}));
109 add(LIST32, new KISSRandom(new int[] {g.nextInt(), g.nextInt(), g.nextInt()}));
110 add(LIST32, new XoRoShiRo64Star(new int[] {g.nextInt(), g.nextInt()}));
111 add(LIST32, new XoRoShiRo64StarStar(new int[] {g.nextInt(), g.nextInt(), g.nextInt()}));
112 add(LIST32, new XoShiRo128Plus(new int[] {g.nextInt(), g.nextInt(), g.nextInt()}));
113 add(LIST32, new XoShiRo128StarStar(new int[] {g.nextInt(), g.nextInt(), g.nextInt()}));
114 add(LIST32, new PcgXshRr32(new long[] {g.nextLong()}));
115 add(LIST32, new PcgXshRs32(new long[] {g.nextLong()}));
116 add(LIST32, new PcgMcgXshRr32(g.nextLong()));
117 add(LIST32, new PcgMcgXshRs32(g.nextLong()));
118
119 add(LIST32, new MiddleSquareWeylSequence(new long[] {g.nextLong(), g.nextLong(), 0xb5ad4eceda1ce2a9L}));
120 add(LIST32, new DotyHumphreySmallFastCounting32(new int[] {g.nextInt(), g.nextInt()}));
121 add(LIST32, new JenkinsSmallFast32(g.nextInt()));
122 add(LIST32, new XoShiRo128PlusPlus(new int[] {g.nextInt(), g.nextInt(), g.nextInt()}));
123
124
125
126 add(LIST64, new SplitMix64(g.nextLong()));
127 add(LIST64, new XorShift1024Star(new long[] {g.nextLong(), g.nextLong(), g.nextLong(), g.nextLong()}));
128 add(LIST64, new XorShift1024StarPhi(new long[] {g.nextLong(), g.nextLong(), g.nextLong(), g.nextLong()}));
129 add(LIST64, new TwoCmres(g.nextInt()));
130 add(LIST64, new TwoCmres(g.nextInt(), 5, 8));
131 add(LIST64, new MersenneTwister64(new long[] {g.nextLong(), g.nextLong(), g.nextLong(), g.nextLong()}));
132 add(LIST64, new XoRoShiRo128Plus(new long[] {g.nextLong(), g.nextLong()}));
133 add(LIST64, new XoRoShiRo128StarStar(new long[] {g.nextLong(), g.nextLong()}));
134 add(LIST64, new XoShiRo256Plus(new long[] {g.nextLong(), g.nextLong(), g.nextLong(), g.nextLong()}));
135 add(LIST64, new XoShiRo256StarStar(new long[] {g.nextLong(), g.nextLong(), g.nextLong(), g.nextLong()}));
136 add(LIST64, new XoShiRo512Plus(new long[] {g.nextLong(), g.nextLong(), g.nextLong(), g.nextLong()}));
137 add(LIST64, new XoShiRo512StarStar(new long[] {g.nextLong(), g.nextLong(), g.nextLong(), g.nextLong()}));
138 add(LIST64, new PcgRxsMXs64(new long[] {g.nextLong()}));
139 add(LIST64, new DotyHumphreySmallFastCounting64(new long[] {g.nextLong(), g.nextLong()}));
140 add(LIST64, new JenkinsSmallFast64(g.nextLong()));
141 add(LIST64, new XoRoShiRo128PlusPlus(new long[] {g.nextLong(), g.nextLong()}));
142 add(LIST64, new XoShiRo256PlusPlus(new long[] {g.nextLong(), g.nextLong(), g.nextLong(), g.nextLong()}));
143 add(LIST64, new XoShiRo512PlusPlus(new long[] {g.nextLong(), g.nextLong(), g.nextLong(), g.nextLong()}));
144 add(LIST64, new XoRoShiRo1024PlusPlus(new long[] {g.nextLong(), g.nextLong(), g.nextLong(), g.nextLong()}));
145 add(LIST64, new XoRoShiRo1024Star(new long[] {g.nextLong(), g.nextLong(), g.nextLong(), g.nextLong()}));
146 add(LIST64, new XoRoShiRo1024StarStar(new long[] {g.nextLong(), g.nextLong(), g.nextLong(), g.nextLong()}));
147
148
149
150
151 LIST.addAll(LIST32);
152 LIST.addAll(LIST64);
153
154 for (RestorableUniformRandomProvider[] rng : LIST) {
155 if (rng[0] instanceof JumpableUniformRandomProvider) {
156 add(LIST_JUMP, (JumpableUniformRandomProvider) rng[0]);
157 }
158 }
159 } catch (Exception e) {
160
161 System.err.println("Unexpected exception while creating the list of generators: " + e);
162 e.printStackTrace(System.err);
163
164 throw new RuntimeException(e);
165 }
166 }
167
168
169
170
171 private ProvidersList() {}
172
173
174
175
176
177 private static void add(List<RestorableUniformRandomProvider[]> list,
178 RestorableUniformRandomProvider rng) {
179 list.add(new RestorableUniformRandomProvider[] {rng});
180 }
181
182
183
184
185
186 private static void add(List<JumpableUniformRandomProvider[]> list,
187 JumpableUniformRandomProvider rng) {
188 list.add(new JumpableUniformRandomProvider[] {rng});
189 }
190
191
192
193
194
195
196
197 public static Iterable<RestorableUniformRandomProvider[]> list() {
198 return Collections.unmodifiableList(LIST);
199 }
200
201
202
203
204
205
206
207 public static Iterable<RestorableUniformRandomProvider[]> list32() {
208 return Collections.unmodifiableList(LIST32);
209 }
210
211
212
213
214
215
216
217 public static Iterable<RestorableUniformRandomProvider[]> list64() {
218 return Collections.unmodifiableList(LIST64);
219 }
220
221
222
223
224
225
226
227 public static Iterable<JumpableUniformRandomProvider[]> listJumpable() {
228 return Collections.unmodifiableList(LIST_JUMP);
229 }
230 }