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 class ProvidersList {
34
35 private static final List<Data[]> LIST = new ArrayList<Data[]>();
36
37 private static final List<Data[]> LIST32 = new ArrayList<Data[]>();
38
39 private static final List<Data[]> LIST64 = new ArrayList<Data[]>();
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
56
57
58 add(LIST64, RandomSource.SPLIT_MIX_64, -988777666655555L);
59 add(LIST64, RandomSource.XOR_SHIFT_1024_S, new long[] { 123456L, 234567L, -345678L });
60 add(LIST64, RandomSource.TWO_CMRES, 55443322);
61 add(LIST64, RandomSource.TWO_CMRES_SELECT, -987654321, 5, 8);
62 add(LIST64, RandomSource.MT_64, new long[] { 1234567L, 2345678L, -3456789L });
63
64
65
66
67 LIST.addAll(LIST32);
68 LIST.addAll(LIST64);
69 } catch (Exception e) {
70 System.err.println("Unexpected exception while creating the list of generators: " + e);
71 e.printStackTrace(System.err);
72 throw new RuntimeException(e);
73 }
74 }
75
76
77
78
79 private ProvidersList() {}
80
81
82
83
84
85 private static void add(List<Data[]> list,
86 RandomSource source,
87 Object ... data) {
88 final RandomSource rng = source;
89 final Object seed = data.length > 0 ? data[0] : null;
90 final Object[] args = data.length > 1 ? Arrays.copyOfRange(data, 1, data.length) : null;
91
92 list.add(new Data[] { new Data(rng, seed, args) });
93 }
94
95
96
97
98
99
100
101 public static Iterable<Data[]> list() {
102 return Collections.unmodifiableList(LIST);
103 }
104
105
106
107
108
109
110
111 public static Iterable<Data[]> list32() {
112 return Collections.unmodifiableList(LIST32);
113 }
114
115
116
117
118
119
120
121 public static Iterable<Data[]> list64() {
122 return Collections.unmodifiableList(LIST64);
123 }
124
125
126
127
128
129 public static class Data {
130 private final RandomSource source;
131 private final Object seed;
132 private final Object[] args;
133
134 public Data(RandomSource source,
135 Object seed,
136 Object[] args) {
137 this.source = source;
138 this.seed = seed;
139 this.args = args;
140 }
141
142 public RandomSource getSource() {
143 return source;
144 }
145
146 public Object getSeed() {
147 return seed;
148 }
149
150 public Object[] getArgs() {
151 return args == null ? null : Arrays.copyOf(args, args.length);
152 }
153
154 @Override
155 public String toString() {
156 return source.toString() + " seed=" + seed + " args=" + Arrays.toString(args);
157 }
158 }
159 }