File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -221,6 +221,29 @@ public func Random() -> Int64 {
221
221
return lfsrRandomGenerator. randInt ( )
222
222
}
223
223
224
+ // This is a fixed-increment version of Java 8's SplittableRandom generator.
225
+ // It is a very fast generator passing BigCrush, with 64 bits of state.
226
+ // See http://dx.doi.org/10.1145/2714064.2660195 and
227
+ // http://docs.oracle.com/javase/8/docs/api/java/util/SplittableRandom.html
228
+ //
229
+ // Derived from public domain C implementation by Sebastiano Vigna
230
+ // See http://xoshiro.di.unimi.it/splitmix64.c
231
+ public struct SplitMix64 : RandomNumberGenerator {
232
+ private var state : UInt64
233
+
234
+ public init ( seed: UInt64 ) {
235
+ self . state = seed
236
+ }
237
+
238
+ public mutating func next( ) -> UInt64 {
239
+ self . state &+= 0x9e3779b97f4a7c15
240
+ var z : UInt64 = self . state
241
+ z = ( z ^ ( z &>> 30 ) ) &* 0xbf58476d1ce4e5b9
242
+ z = ( z ^ ( z &>> 27 ) ) &* 0x94d049bb133111eb
243
+ return z ^ ( z &>> 31 )
244
+ }
245
+ }
246
+
224
247
@inlinable // FIXME(inline-always)
225
248
@inline ( __always)
226
249
public func CheckResults(
You can’t perform that action at this time.
0 commit comments