Skip to content

Commit

Permalink
[Swift 6] Enable experimental feature StrictConcurrency in ForceSimul…
Browse files Browse the repository at this point in the history
…ation package
  • Loading branch information
Walker Haynes committed Jun 17, 2024
1 parent 3146058 commit 84c45f7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 27 deletions.
5 changes: 4 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ let package = Package(

.target(
name: "ForceSimulation",
path: "Sources/ForceSimulation"
path: "Sources/ForceSimulation",
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency")
]
),

.target(
Expand Down
26 changes: 0 additions & 26 deletions Sources/ForceSimulation/Utils/LinearCongruentialGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
public protocol DeterministicRandomGenerator<Scalar> {
associatedtype Scalar where Scalar: FloatingPoint & ExpressibleByFloatLiteral
associatedtype OverflowingInteger: FixedWidthInteger & UnsignedInteger
@inlinable static func next() -> Scalar
@inlinable mutating func next() -> Scalar
@inlinable init(seed: OverflowingInteger)
@inlinable init()
Expand All @@ -15,7 +14,6 @@ public struct DoubleLinearCongruentialGenerator: DeterministicRandomGenerator {
public typealias OverflowingInteger = UInt32
@usableFromInline internal static let a: UInt32 = 1_664_525
@usableFromInline internal static let c: UInt32 = 1_013_904_223
@usableFromInline internal static var _s: UInt32 = 1
@usableFromInline internal var s: UInt32 = 1
@usableFromInline internal static let m: Double = 4_294_967_296

Expand All @@ -29,14 +27,6 @@ public struct DoubleLinearCongruentialGenerator: DeterministicRandomGenerator {
return Double(s) / Self.m
}

@inlinable public static func next() -> Double {

Self._s = (Self.a &* Self._s) &+ Self.c

// Convert the result to Double and divide by m to normalize it.
return Double(Self._s) / Self.m
}

@inlinable public init(seed: OverflowingInteger) {
self.s = 1 //seed
}
Expand All @@ -51,7 +41,6 @@ public struct FloatLinearCongruentialGenerator: DeterministicRandomGenerator {
public typealias OverflowingInteger = UInt16
@usableFromInline internal static let a: UInt16 = 75
@usableFromInline internal static let c: UInt16 = 74
@usableFromInline internal static var _s: UInt16 = 1
@usableFromInline internal var s: UInt16 = 1
@usableFromInline internal static let m: Float = 65537.0

Expand All @@ -64,13 +53,6 @@ public struct FloatLinearCongruentialGenerator: DeterministicRandomGenerator {
return Float(s) / Self.m
}

@inlinable public static func next() -> Float {
_s = (a &* _s) &+ c

// Convert the result to Float and divide by m to normalize it.
return Float(_s) / Self.m
}

@inlinable public init(seed: OverflowingInteger) {
self.s = seed
}
Expand Down Expand Up @@ -100,14 +82,6 @@ extension HasDeterministicRandomGenerator {
return 1e-5
}

@inlinable
public func jiggled() -> Self {
if self == .zero || self.isNaN {
return (Generator.next() - 0.5) * Self.jigglingScale
}
return self
}

@inlinable
public func jiggled(by: UnsafeMutablePointer<Generator>) -> Self {
if self == .zero || self.isNaN {
Expand Down

0 comments on commit 84c45f7

Please sign in to comment.