Skip to content
This repository was archived by the owner on Jul 1, 2023. It is now read-only.

Commit 8c228db

Browse files
committed
Random distributions should be structs, not classes.
1 parent 2c08006 commit 8c228db

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Sources/DeepLearning/Random.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ public protocol SeedableRandomNumberGenerator: RandomNumberGenerator {
4141
init<T: BinaryInteger>(seed: T)
4242
}
4343

44-
extension SeedableRandomNumberGenerator {
45-
public init<T: BinaryInteger>(seed: T) {
44+
public extension SeedableRandomNumberGenerator {
45+
init<T: BinaryInteger>(seed: T) {
4646
var newSeed: [UInt8] = []
4747
for i in 0..<seed.bitWidth / UInt8.bitWidth {
4848
newSeed.append(UInt8(truncatingIfNeeded: seed >> (UInt8.bitWidth * i)))
@@ -414,7 +414,7 @@ public protocol RandomDistribution {
414414
}
415415

416416
@_fixed_layout
417-
public final class UniformIntegerDistribution<T: FixedWidthInteger>: RandomDistribution {
417+
public struct UniformIntegerDistribution<T: FixedWidthInteger>: RandomDistribution {
418418
public let lowerBound: T
419419
public let upperBound: T
420420

@@ -429,7 +429,7 @@ public final class UniformIntegerDistribution<T: FixedWidthInteger>: RandomDistr
429429
}
430430

431431
@_fixed_layout
432-
public final class UniformFloatingPointDistribution<T : BinaryFloatingPoint>: RandomDistribution
432+
public struct UniformFloatingPointDistribution<T : BinaryFloatingPoint>: RandomDistribution
433433
where T.RawSignificand : FixedWidthInteger {
434434
public let lowerBound: T
435435
public let upperBound: T
@@ -445,7 +445,7 @@ public final class UniformFloatingPointDistribution<T : BinaryFloatingPoint>: Ra
445445
}
446446

447447
@_fixed_layout
448-
public final class NormalDistribution<T : BinaryFloatingPoint>: RandomDistribution
448+
public struct NormalDistribution<T : BinaryFloatingPoint>: RandomDistribution
449449
where T.RawSignificand : FixedWidthInteger {
450450
public let mean: T
451451
public let standardDeviation: T
@@ -469,7 +469,7 @@ public final class NormalDistribution<T : BinaryFloatingPoint>: RandomDistributi
469469
}
470470

471471
@_fixed_layout
472-
public final class BetaDistribution: RandomDistribution {
472+
public struct BetaDistribution: RandomDistribution {
473473
public let alpha: Float
474474
public let beta: Float
475475
private let uniformDistribution = UniformFloatingPointDistribution<Float>()

0 commit comments

Comments
 (0)