rename
This commit is contained in:
21
Sources/ECGSynKit/SplitMix64.swift
Normal file
21
Sources/ECGSynKit/SplitMix64.swift
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
struct SplitMix64 : RandomNumberGenerator {
|
||||
public typealias State = UInt64
|
||||
public private(set) var state: State
|
||||
|
||||
init(state: UInt64) {
|
||||
self.state = state
|
||||
}
|
||||
|
||||
public mutating func next() -> UInt64 {
|
||||
state &+= 0x9E3779B97F4A7C15
|
||||
var z = state
|
||||
z = (z ^ (z >> 30)) &* 0xBF58476D1CE4E5B9
|
||||
z = (z ^ (z >> 27)) &* 0x94D049BB133111EB
|
||||
return z ^ (z >> 31)
|
||||
}
|
||||
|
||||
public mutating func nextDouble() -> Double {
|
||||
Double(next() >> 11) * 0x1.0p-53
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user