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.Arrays;
20 import java.util.List;
21 import java.util.ArrayList;
22 import java.util.Collections;
23 import java.security.SecureRandom;
24
25 import org.apache.commons.rng.core.source32.JDKRandom;
26 import org.apache.commons.rng.core.source32.Well512a;
27 import org.apache.commons.rng.core.source32.Well1024a;
28 import org.apache.commons.rng.core.source32.Well19937a;
29 import org.apache.commons.rng.core.source32.Well19937c;
30 import org.apache.commons.rng.core.source32.Well44497a;
31 import org.apache.commons.rng.core.source32.Well44497b;
32 import org.apache.commons.rng.core.source32.ISAACRandom;
33 import org.apache.commons.rng.core.source32.MersenneTwister;
34 import org.apache.commons.rng.core.source32.MultiplyWithCarry256;
35 import org.apache.commons.rng.core.source32.KISSRandom;
36 import org.apache.commons.rng.core.source64.SplitMix64;
37 import org.apache.commons.rng.core.source64.XorShift1024Star;
38 import org.apache.commons.rng.core.source64.TwoCmres;
39 import org.apache.commons.rng.core.source64.MersenneTwister64;
40 import org.apache.commons.rng.RestorableUniformRandomProvider;
41
42
43
44
45
46
47
48
49
50
51 public class ProvidersList {
52
53 private static final List<RestorableUniformRandomProvider[]> LIST =
54 new ArrayList<RestorableUniformRandomProvider[]>();
55
56 private static final List<RestorableUniformRandomProvider[]> LIST32 =
57 new ArrayList<RestorableUniformRandomProvider[]>();
58
59 private static final List<RestorableUniformRandomProvider[]> LIST64 =
60 new ArrayList<RestorableUniformRandomProvider[]>();
61
62 static {
63
64 final SecureRandom g = new SecureRandom();
65
66 try {
67
68 add(LIST32, new JDKRandom(g.nextLong()));
69 add(LIST32, new MersenneTwister(new int[] { g.nextInt(), g.nextInt(), g.nextInt() }));
70 add(LIST32, new Well512a(new int[] { g.nextInt(), g.nextInt(), g.nextInt() }));
71 add(LIST32, new Well1024a(new int[] { g.nextInt(), g.nextInt(), g.nextInt() }));
72 add(LIST32, new Well19937a(new int[] { g.nextInt(), g.nextInt(), g.nextInt() }));
73 add(LIST32, new Well19937c(new int[] { g.nextInt(), g.nextInt(), g.nextInt() }));
74 add(LIST32, new Well44497a(new int[] { g.nextInt(), g.nextInt(), g.nextInt() }));
75 add(LIST32, new Well44497b(new int[] { g.nextInt(), g.nextInt(), g.nextInt() }));
76 add(LIST32, new ISAACRandom(new int[] { g.nextInt(), g.nextInt(), g.nextInt() }));
77 add(LIST32, new MultiplyWithCarry256(new int[] { g.nextInt(), g.nextInt(), g.nextInt() }));
78 add(LIST32, new KISSRandom(new int[] { g.nextInt(), g.nextInt(), g.nextInt() }));
79
80
81
82 add(LIST64, new SplitMix64(g.nextLong()));
83 add(LIST64, new XorShift1024Star(new long[] { g.nextLong(), g.nextLong(), g.nextLong(), g.nextLong() }));
84 add(LIST64, new TwoCmres(g.nextInt()));
85 add(LIST64, new TwoCmres(g.nextInt(), 5, 8));
86 add(LIST64, new MersenneTwister64(new long[] { g.nextLong(), g.nextLong(), g.nextLong(), g.nextLong() }));
87
88
89
90
91 LIST.addAll(LIST32);
92 LIST.addAll(LIST64);
93 } catch (Exception e) {
94 System.err.println("Unexpected exception while creating the list of generators: " + e);
95 e.printStackTrace(System.err);
96 throw new RuntimeException(e);
97 }
98 }
99
100
101
102
103 private ProvidersList() {}
104
105
106
107
108
109 private static void add(List<RestorableUniformRandomProvider[]> list,
110 RestorableUniformRandomProvider rng) {
111 list.add(new RestorableUniformRandomProvider[] { rng });
112 }
113
114
115
116
117
118
119
120 public static Iterable<RestorableUniformRandomProvider[]> list() {
121 return Collections.unmodifiableList(LIST);
122 }
123
124
125
126
127
128
129
130 public static Iterable<RestorableUniformRandomProvider[]> list32() {
131 return Collections.unmodifiableList(LIST32);
132 }
133
134
135
136
137
138
139
140 public static Iterable<RestorableUniformRandomProvider[]> list64() {
141 return Collections.unmodifiableList(LIST64);
142 }
143 }