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