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

Commit 1e5758a

Browse files
committed
public -> internal.
1 parent 3e1d56e commit 1e5758a

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

Sources/third_party/Complex/Complex.swift

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
11
// A major part of the Complex number implementation comes from
22
// [@xwu](https://github.com/xwu)'s project, [NumericAnnex](https://github.com/xwu/NumericAnnex).
33

4-
public struct Complex<T : FloatingPoint> {
5-
public var real: T
6-
public var imaginary: T
4+
struct Complex<T : FloatingPoint> {
5+
var real: T
6+
var imaginary: T
77

88
@differentiable(vjp: _vjpInit where T : Differentiable, T.TangentVector == T)
9-
public init(real: T = 0, imaginary: T = 0) {
9+
init(real: T = 0, imaginary: T = 0) {
1010
self.real = real
1111
self.imaginary = imaginary
1212
}
1313
}
1414

1515
extension Complex : Differentiable where T : Differentiable {
16-
public typealias TangentVector = Complex
17-
public typealias AllDifferentiableVariables = Complex
16+
typealias TangentVector = Complex
17+
typealias AllDifferentiableVariables = Complex
1818
}
1919

2020
extension Complex {
21-
public static var i: Complex {
21+
static var i: Complex {
2222
return Complex(real: 0, imaginary: 1)
2323
}
2424

25-
public var isFinite: Bool {
25+
var isFinite: Bool {
2626
return real.isFinite && imaginary.isFinite
2727
}
2828

29-
public var isInfinite: Bool {
29+
var isInfinite: Bool {
3030
return real.isInfinite || imaginary.isInfinite
3131
}
3232

33-
public var isNaN: Bool {
33+
var isNaN: Bool {
3434
return (real.isNaN && !imaginary.isInfinite) ||
3535
(imaginary.isNaN && !real.isInfinite)
3636
}
3737

38-
public var isZero: Bool {
38+
var isZero: Bool {
3939
return real.isZero && imaginary.isZero
4040
}
4141
}
4242

4343
extension Complex : ExpressibleByIntegerLiteral {
44-
public init(integerLiteral value: Int) {
44+
init(integerLiteral value: Int) {
4545
self.real = T(value)
4646
self.imaginary = 0
4747
}
4848
}
4949

5050
extension Complex : CustomStringConvertible {
51-
public var description: String {
51+
var description: String {
5252
return real.isNaN && real.sign == .minus
5353
? imaginary.sign == .minus
5454
? "-\(-real) - \(-imaginary)i"
@@ -60,46 +60,46 @@ extension Complex : CustomStringConvertible {
6060
}
6161

6262
extension Complex : Equatable {
63-
public static func == (lhs: Complex, rhs: Complex) -> Bool {
63+
c static func == (lhs: Complex, rhs: Complex) -> Bool {
6464
return lhs.real == rhs.real && lhs.imaginary == rhs.imaginary
6565
}
6666
}
6767

6868
extension Complex : AdditiveArithmetic {
6969
@differentiable(vjp: _vjpAdd(lhs:rhs:) where T : Differentiable)
70-
public static func + (lhs: Complex, rhs: Complex) -> Complex {
70+
static func + (lhs: Complex, rhs: Complex) -> Complex {
7171
var temp = lhs
7272
temp += rhs
7373
return temp
7474
}
7575

76-
public static func += (lhs: inout Complex, rhs: Complex) {
76+
static func += (lhs: inout Complex, rhs: Complex) {
7777
lhs.real += rhs.real
7878
lhs.imaginary += rhs.imaginary
7979
}
8080

8181
@differentiable(vjp: _vjpSubtract(lhs:rhs:) where T : Differentiable)
82-
public static func - (lhs: Complex, rhs: Complex) -> Complex {
82+
static func - (lhs: Complex, rhs: Complex) -> Complex {
8383
var temp = lhs
8484
temp -= rhs
8585
return temp
8686
}
8787

88-
public static func -= (lhs: inout Complex, rhs: Complex) {
88+
static func -= (lhs: inout Complex, rhs: Complex) {
8989
lhs.real -= rhs.real
9090
lhs.imaginary -= rhs.imaginary
9191
}
9292
}
9393

9494
extension Complex : Numeric {
95-
public init?<U>(exactly source: U) where U : BinaryInteger {
95+
init?<U>(exactly source: U) where U : BinaryInteger {
9696
guard let t = T(exactly: source) else { return nil }
9797
self.real = t
9898
self.imaginary = 0
9999
}
100100

101101
@differentiable(vjp: _vjpMultiply(lhs:rhs:) where T : Differentiable)
102-
public static func * (lhs: Complex, rhs: Complex) -> Complex {
102+
static func * (lhs: Complex, rhs: Complex) -> Complex {
103103
var a = lhs.real, b = lhs.imaginary, c = rhs.real, d = rhs.imaginary
104104
let ac = a * c, bd = b * d, ad = a * d, bc = b * c
105105
let x = ac - bd
@@ -139,11 +139,11 @@ extension Complex : Numeric {
139139
return Complex(real: x, imaginary: y)
140140
}
141141

142-
public static func *= (lhs: inout Complex, rhs: Complex) {
142+
static func *= (lhs: inout Complex, rhs: Complex) {
143143
lhs = lhs * rhs
144144
}
145145

146-
public var magnitude: T {
146+
var magnitude: T {
147147
var x = abs(real)
148148
var y = abs(imaginary)
149149
if x.isInfinite { return x }
@@ -157,19 +157,19 @@ extension Complex : Numeric {
157157

158158
extension Complex : SignedNumeric {
159159
@differentiable(vjp: _vjpNegate where T : Differentiable)
160-
public static prefix func - (operand: Complex) -> Complex {
160+
static prefix func - (operand: Complex) -> Complex {
161161
return Complex(real: -operand.real, imaginary: -operand.imaginary)
162162
}
163163

164-
public mutating func negate() {
164+
mutating func negate() {
165165
real.negate()
166166
imaginary.negate()
167167
}
168168
}
169169

170170
extension Complex {
171171
@differentiable(vjp: _vjpDivide(lhs:rhs:) where T : Differentiable)
172-
public static func / (lhs: Complex, rhs: Complex) -> Complex {
172+
static func / (lhs: Complex, rhs: Complex) -> Complex {
173173
var a = lhs.real, b = lhs.imaginary, c = rhs.real, d = rhs.imaginary
174174
var x: T
175175
var y: T
@@ -204,27 +204,27 @@ extension Complex {
204204
}
205205

206206

207-
public static func /= (lhs: inout Complex, rhs: Complex) {
207+
static func /= (lhs: inout Complex, rhs: Complex) {
208208
lhs = lhs / rhs
209209
}
210210
}
211211

212212
extension Complex {
213213
@differentiable(vjp: _vjpComplexConjugate where T : Differentiable)
214-
public func complexConjugate() -> Complex {
214+
func complexConjugate() -> Complex {
215215
return Complex(real: real, imaginary: -imaginary)
216216
}
217217
}
218218

219-
public func abs<T>(_ z: Complex<T>) -> Complex<T> {
219+
func abs<T>(_ z: Complex<T>) -> Complex<T> {
220220
return Complex(real: z.magnitude)
221221
}
222222

223223
extension Complex {
224224
@differentiable(vjp: _vjpAdding(real:)
225225
where T : Differentiable,
226226
T.TangentVector == T)
227-
public func adding(real: T) -> Complex {
227+
func adding(real: T) -> Complex {
228228
var c = self
229229
c.real += real
230230
return c
@@ -233,7 +233,7 @@ extension Complex {
233233
@differentiable(vjp: _vjpSubtracting(real:)
234234
where T : Differentiable,
235235
T.TangentVector == T)
236-
public func subtracting(real: T) -> Complex {
236+
func subtracting(real: T) -> Complex {
237237
var c = self
238238
c.real -= real
239239
return c
@@ -242,7 +242,7 @@ extension Complex {
242242
@differentiable(vjp: _vjpAdding(imaginary:)
243243
where T : Differentiable,
244244
T.TangentVector == T)
245-
public func adding(imaginary: T) -> Complex {
245+
func adding(imaginary: T) -> Complex {
246246
var c = self
247247
c.imaginary += imaginary
248248
return c
@@ -251,7 +251,7 @@ extension Complex {
251251
@differentiable(vjp: _vjpSubtracting(imaginary:)
252252
where T : Differentiable,
253253
T.TangentVector == T)
254-
public func subtracting(imaginary: T) -> Complex {
254+
func subtracting(imaginary: T) -> Complex {
255255
var c = self
256256
c.imaginary -= imaginary
257257
return c

0 commit comments

Comments
 (0)