Skip to content

Commit 9895bd3

Browse files
Merge pull request #3 from SomeRandomiOSDev/1.1.0_Componentwise
Added component-wise arithmetic operations
2 parents d504184 + 52a49f0 commit 9895bd3

File tree

5 files changed

+200
-0
lines changed

5 files changed

+200
-0
lines changed

.swiftlint.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ opt_in_rules:
5757

5858
reporter: "xcode"
5959

60+
excluded:
61+
- Carthage
62+
6063
identifier_name:
6164
excluded:
6265
- i

Complex.xcodeproj/project.pbxproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949
DDB8122123F656AC0079FEB5 /* FunctionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDB8122023F656AC0079FEB5 /* FunctionsTests.swift */; };
5050
DDB8122223F656AC0079FEB5 /* FunctionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDB8122023F656AC0079FEB5 /* FunctionsTests.swift */; };
5151
DDB8122323F656AC0079FEB5 /* FunctionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDB8122023F656AC0079FEB5 /* FunctionsTests.swift */; };
52+
DDB8125923F707EE0079FEB5 /* Operators.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDB8125823F707EE0079FEB5 /* Operators.swift */; };
53+
DDB8125A23F707EE0079FEB5 /* Operators.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDB8125823F707EE0079FEB5 /* Operators.swift */; };
54+
DDB8125B23F707EE0079FEB5 /* Operators.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDB8125823F707EE0079FEB5 /* Operators.swift */; };
55+
DDB8125C23F707EE0079FEB5 /* Operators.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDB8125823F707EE0079FEB5 /* Operators.swift */; };
5256
DDB8126223F7B1C90079FEB5 /* ComplexArithmetic.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDB8126123F7B1C90079FEB5 /* ComplexArithmetic.swift */; };
5357
DDB8126323F7B1C90079FEB5 /* ComplexArithmetic.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDB8126123F7B1C90079FEB5 /* ComplexArithmetic.swift */; };
5458
DDB8126423F7B1C90079FEB5 /* ComplexArithmetic.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDB8126123F7B1C90079FEB5 /* ComplexArithmetic.swift */; };
@@ -150,6 +154,7 @@
150154
DDB8121B23F63B890079FEB5 /* Half.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Half.framework; path = Carthage/Build/Mac/Half.framework; sourceTree = "<group>"; };
151155
DDB8121C23F63B900079FEB5 /* Half.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Half.framework; path = Carthage/Build/iOS/Half.framework; sourceTree = "<group>"; };
152156
DDB8122023F656AC0079FEB5 /* FunctionsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FunctionsTests.swift; sourceTree = "<group>"; };
157+
DDB8125823F707EE0079FEB5 /* Operators.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Operators.swift; sourceTree = "<group>"; };
153158
DDB8126123F7B1C90079FEB5 /* ComplexArithmetic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComplexArithmetic.swift; sourceTree = "<group>"; };
154159
DDB8126623F7B7F40079FEB5 /* ComplexArithmeticTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ComplexArithmeticTests.swift; sourceTree = "<group>"; };
155160
DDB8126B23FA2B950079FEB5 /* gyb.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = gyb.py; sourceTree = "<group>"; };
@@ -337,6 +342,7 @@
337342
DDB8126123F7B1C90079FEB5 /* ComplexArithmetic.swift */,
338343
DDB8126F23FA2C210079FEB5 /* Functions.swift.gyb */,
339344
DDB8120B23F5A8E80079FEB5 /* Functions.swift */,
345+
DDB8125823F707EE0079FEB5 /* Operators.swift */,
340346
);
341347
path = Complex;
342348
sourceTree = "<group>";
@@ -682,6 +688,7 @@
682688
buildActionMask = 2147483647;
683689
files = (
684690
DDB8126223F7B1C90079FEB5 /* ComplexArithmetic.swift in Sources */,
691+
DDB8125923F707EE0079FEB5 /* Operators.swift in Sources */,
685692
DDB8120723F59B760079FEB5 /* Complex.swift in Sources */,
686693
DDB8120C23F5A8E80079FEB5 /* Functions.swift in Sources */,
687694
);
@@ -702,6 +709,7 @@
702709
buildActionMask = 2147483647;
703710
files = (
704711
DDB8126323F7B1C90079FEB5 /* ComplexArithmetic.swift in Sources */,
712+
DDB8125A23F707EE0079FEB5 /* Operators.swift in Sources */,
705713
DDB8120823F59B760079FEB5 /* Complex.swift in Sources */,
706714
DDB8120D23F5A8E80079FEB5 /* Functions.swift in Sources */,
707715
);
@@ -722,6 +730,7 @@
722730
buildActionMask = 2147483647;
723731
files = (
724732
DDB8126423F7B1C90079FEB5 /* ComplexArithmetic.swift in Sources */,
733+
DDB8125B23F707EE0079FEB5 /* Operators.swift in Sources */,
725734
DDB8120923F59B760079FEB5 /* Complex.swift in Sources */,
726735
DDB8120E23F5A8E80079FEB5 /* Functions.swift in Sources */,
727736
);
@@ -742,6 +751,7 @@
742751
buildActionMask = 2147483647;
743752
files = (
744753
DDB8126523F7B1C90079FEB5 /* ComplexArithmetic.swift in Sources */,
754+
DDB8125C23F707EE0079FEB5 /* Operators.swift in Sources */,
745755
DDB8120A23F59B760079FEB5 /* Complex.swift in Sources */,
746756
DDB8120F23F5A8E80079FEB5 /* Functions.swift in Sources */,
747757
);

Sources/Complex/ComplexArithmetic.swift

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@ extension Complex {
6060

6161
//
6262

63+
@inlinable @inline(__always)
64+
public static func .+ (lhs: Complex<Scalar>, rhs: Complex<Scalar>) -> Complex<Scalar> {
65+
return lhs + rhs
66+
}
67+
68+
@inlinable @inline(__always)
69+
public static func .+= (lhs: inout Complex<Scalar>, rhs: Complex<Scalar>) {
70+
lhs = lhs .+ rhs
71+
}
72+
73+
//
74+
6375
@_transparent
6476
public static func - (lhs: Complex<Scalar>, rhs: Scalar) -> Complex<Scalar> {
6577
return Complex<Scalar>(real: lhs.real - rhs, imaginary: lhs.imaginary)
@@ -69,6 +81,18 @@ extension Complex {
6981
public static func -= (lhs: inout Complex<Scalar>, rhs: Scalar) {
7082
lhs = lhs - rhs
7183
}
84+
85+
//
86+
87+
@inlinable @inline(__always)
88+
public static func .- (lhs: Complex<Scalar>, rhs: Complex<Scalar>) -> Complex<Scalar> {
89+
return lhs - rhs
90+
}
91+
92+
@inlinable @inline(__always)
93+
public static func .-= (lhs: inout Complex<Scalar>, rhs: Complex<Scalar>) {
94+
lhs = lhs .- rhs
95+
}
7296
}
7397

7498
extension Complex where Scalar: SignedNumeric {
@@ -112,6 +136,18 @@ extension Complex {
112136
public static func *= (lhs: inout Complex<Scalar>, rhs: Scalar) {
113137
lhs = lhs * rhs
114138
}
139+
140+
//
141+
142+
@_transparent
143+
public static func .* (lhs: Complex<Scalar>, rhs: Complex<Scalar>) -> Complex<Scalar> {
144+
return Complex<Scalar>(real: lhs.real * rhs.real, imaginary: lhs.imaginary * rhs.imaginary)
145+
}
146+
147+
@_transparent
148+
public static func .*= (lhs: inout Complex<Scalar>, rhs: Complex<Scalar>) {
149+
lhs = lhs .* rhs
150+
}
115151
}
116152

117153
// MARK: - Division (BinaryInteger)
@@ -143,6 +179,18 @@ extension Complex where Scalar: BinaryInteger {
143179
public static func /= (lhs: inout Complex<Scalar>, rhs: Scalar) {
144180
lhs = lhs / rhs
145181
}
182+
183+
//
184+
185+
@_transparent
186+
public static func ./ (lhs: Complex<Scalar>, rhs: Complex<Scalar>) -> Complex<Scalar> {
187+
return Complex<Scalar>(real: lhs.real / rhs.real, imaginary: lhs.imaginary / rhs.imaginary)
188+
}
189+
190+
@_transparent
191+
public static func ./= (lhs: inout Complex<Scalar>, rhs: Complex<Scalar>) {
192+
lhs = lhs ./ rhs
193+
}
146194
}
147195

148196
// MARK: - Division (SignedInteger)
@@ -188,4 +236,16 @@ extension Complex where Scalar: FloatingPoint {
188236
public static func /= (lhs: inout Complex<Scalar>, rhs: Scalar) {
189237
lhs = lhs / rhs
190238
}
239+
240+
//
241+
242+
@_transparent
243+
public static func ./ (lhs: Complex<Scalar>, rhs: Complex<Scalar>) -> Complex<Scalar> {
244+
return Complex<Scalar>(real: lhs.real / rhs.real, imaginary: lhs.imaginary / rhs.imaginary)
245+
}
246+
247+
@_transparent
248+
public static func ./= (lhs: inout Complex<Scalar>, rhs: Complex<Scalar>) {
249+
lhs = lhs ./ rhs
250+
}
191251
}

Sources/Complex/Operators.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//
2+
// Operators.swift
3+
// Complex
4+
//
5+
// Copyright © 2020 SomeRandomiOSDev. All rights reserved.
6+
//
7+
8+
import Foundation
9+
10+
/// Component-wise addition
11+
infix operator .+: AdditionPrecedence
12+
infix operator .+=: AssignmentPrecedence
13+
14+
/// Component-wise subtraction
15+
infix operator .-: AdditionPrecedence
16+
infix operator .-=: AssignmentPrecedence
17+
18+
/// Component-wise multiplication
19+
infix operator .*: MultiplicationPrecedence
20+
infix operator .*=: AssignmentPrecedence
21+
22+
/// Component-wise division
23+
infix operator ./: MultiplicationPrecedence
24+
infix operator ./=: AssignmentPrecedence

Tests/ComplexTests/ComplexArithmeticTests.swift

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,23 @@ class ComplexArithmeticTests: XCTestCase {
160160
testMultiplication(Complex<Float80>(real: 3.0, imaginary: 4.0), 2.0)
161161
}
162162

163+
func testComponentwiseMultiplication() {
164+
testComponentwiseMultiplication(Complex<Int8>(real: 3, imaginary: 4), Complex<Int8>(real: 1, imaginary: 2))
165+
testComponentwiseMultiplication(Complex<Int16>(real: 3, imaginary: 4), Complex<Int16>(real: 1, imaginary: 2))
166+
testComponentwiseMultiplication(Complex<Int32>(real: 3, imaginary: 4), Complex<Int32>(real: 1, imaginary: 2))
167+
testComponentwiseMultiplication(Complex<Int64>(real: 3, imaginary: 4), Complex<Int64>(real: 1, imaginary: 2))
168+
testComponentwiseMultiplication(Complex<Int>(real: 3, imaginary: 4), Complex<Int>(real: 1, imaginary: 2))
169+
testComponentwiseMultiplication(Complex<UInt8>(real: 3, imaginary: 4), Complex<UInt8>(real: 1, imaginary: 2))
170+
testComponentwiseMultiplication(Complex<UInt16>(real: 3, imaginary: 4), Complex<UInt16>(real: 1, imaginary: 2))
171+
testComponentwiseMultiplication(Complex<UInt32>(real: 3, imaginary: 4), Complex<UInt32>(real: 1, imaginary: 2))
172+
testComponentwiseMultiplication(Complex<UInt64>(real: 3, imaginary: 4), Complex<UInt64>(real: 1, imaginary: 2))
173+
testComponentwiseMultiplication(Complex<UInt>(real: 3, imaginary: 4), Complex<UInt>(real: 1, imaginary: 2))
174+
testComponentwiseMultiplication(Complex<Half>(real: 3.0, imaginary: 4.0), Complex<Half>(real: 1.0, imaginary: 2.0))
175+
testComponentwiseMultiplication(Complex<Float>(real: 3.0, imaginary: 4.0), Complex<Float>(real: 1.0, imaginary: 2.0))
176+
testComponentwiseMultiplication(Complex<Double>(real: 3.0, imaginary: 4.0), Complex<Double>(real: 1.0, imaginary: 2.0))
177+
testComponentwiseMultiplication(Complex<Float80>(real: 3.0, imaginary: 4.0), Complex<Float80>(real: 1.0, imaginary: 2.0))
178+
}
179+
163180
func testDivision() {
164181
testDivision(Complex<Int8>(real: 3, imaginary: 4), Complex<Int8>(real: 2, imaginary: 1), Complex<Int8>(real: 2, imaginary: 1))
165182
testDivision(Complex<Int16>(real: 3, imaginary: 4), Complex<Int16>(real: 2, imaginary: 1), Complex<Int16>(real: 2, imaginary: 1))
@@ -192,10 +209,28 @@ class ComplexArithmeticTests: XCTestCase {
192209
testDivision(Complex<Float80>(real: 3.0, imaginary: 4.0), 2.0)
193210
}
194211

212+
func testComponentwiseDivision() {
213+
testComponentwiseDivision(Complex<Int8>(real: 3, imaginary: 4), Complex<Int8>(real: 1, imaginary: 2))
214+
testComponentwiseDivision(Complex<Int16>(real: 3, imaginary: 4), Complex<Int16>(real: 1, imaginary: 2))
215+
testComponentwiseDivision(Complex<Int32>(real: 3, imaginary: 4), Complex<Int32>(real: 1, imaginary: 2))
216+
testComponentwiseDivision(Complex<Int64>(real: 3, imaginary: 4), Complex<Int64>(real: 1, imaginary: 2))
217+
testComponentwiseDivision(Complex<Int>(real: 3, imaginary: 4), Complex<Int>(real: 1, imaginary: 2))
218+
testComponentwiseDivision(Complex<UInt8>(real: 3, imaginary: 4), Complex<UInt8>(real: 1, imaginary: 2))
219+
testComponentwiseDivision(Complex<UInt16>(real: 3, imaginary: 4), Complex<UInt16>(real: 1, imaginary: 2))
220+
testComponentwiseDivision(Complex<UInt32>(real: 3, imaginary: 4), Complex<UInt32>(real: 1, imaginary: 2))
221+
testComponentwiseDivision(Complex<UInt64>(real: 3, imaginary: 4), Complex<UInt64>(real: 1, imaginary: 2))
222+
testComponentwiseDivision(Complex<UInt>(real: 3, imaginary: 4), Complex<UInt>(real: 1, imaginary: 2))
223+
testComponentwiseDivision(Complex<Half>(real: 3.0, imaginary: 4.0), Complex<Half>(real: 1.0, imaginary: 2.0))
224+
testComponentwiseDivision(Complex<Float>(real: 3.0, imaginary: 4.0), Complex<Float>(real: 1.0, imaginary: 2.0))
225+
testComponentwiseDivision(Complex<Double>(real: 3.0, imaginary: 4.0), Complex<Double>(real: 1.0, imaginary: 2.0))
226+
testComponentwiseDivision(Complex<Float80>(real: 3.0, imaginary: 4.0), Complex<Float80>(real: 1.0, imaginary: 2.0))
227+
}
228+
195229
// MARK: Private Methods
196230

197231
private func testAdditionWithZero<Scalar>(_ complex: Complex<Scalar>, file: StaticString = #file, line: UInt = #line) {
198232
XCTAssertEqual(complex, complex + .zero, file: file, line: line)
233+
XCTAssertEqual(complex, complex .+ .zero, file: file, line: line)
199234
XCTAssertEqual(complex, complex + Scalar.zero, file: file, line: line)
200235
XCTAssertEqual(complex, Scalar.zero + complex, file: file, line: line)
201236

@@ -204,6 +239,7 @@ class ComplexArithmeticTests: XCTestCase {
204239
XCTAssertEqual(result, complex, file: file, line: line)
205240

206241
result = complex
242+
result .+= .zero
207243
XCTAssertEqual(result, complex, file: file, line: line)
208244

209245
result = complex
@@ -213,26 +249,36 @@ class ComplexArithmeticTests: XCTestCase {
213249

214250
private func testSubtractionWithZero<Scalar>(_ complex: Complex<Scalar>, file: StaticString = #file, line: UInt = #line) {
215251
XCTAssertEqual(complex, complex - .zero, file: file, line: line)
252+
XCTAssertEqual(complex, complex .- .zero, file: file, line: line)
216253
XCTAssertEqual(complex, complex - Scalar.zero, file: file, line: line)
217254

218255
var result = complex
219256
result -= .zero
220257
XCTAssertEqual(result, complex, file: file, line: line)
221258

259+
result = complex
260+
result .-= .zero
261+
XCTAssertEqual(result, complex, file: file, line: line)
262+
222263
result = complex
223264
result -= Scalar.zero
224265
XCTAssertEqual(result, complex, file: file, line: line)
225266
}
226267

227268
private func testMultiplicationWithZero<Scalar>(_ complex: Complex<Scalar>, file: StaticString = #file, line: UInt = #line) {
228269
XCTAssertEqual(.zero, complex * .zero, file: file, line: line)
270+
XCTAssertEqual(.zero, complex .* .zero, file: file, line: line)
229271
XCTAssertEqual(.zero, complex * Scalar.zero, file: file, line: line)
230272
XCTAssertEqual(.zero, Scalar.zero * complex, file: file, line: line)
231273

232274
var result = complex
233275
result *= .zero
234276
XCTAssertEqual(result, .zero, file: file, line: line)
235277

278+
result = complex
279+
result .*= .zero
280+
XCTAssertEqual(result, .zero, file: file, line: line)
281+
236282
result = complex
237283
result *= Scalar.zero
238284
XCTAssertEqual(result, .zero, file: file, line: line)
@@ -241,6 +287,8 @@ class ComplexArithmeticTests: XCTestCase {
241287
private func testAddition<Scalar>(_ lhs: Complex<Scalar>, _ rhs: Complex<Scalar>, _ result: Complex<Scalar>, file: StaticString = #file, line: UInt = #line) {
242288
XCTAssertEqual(lhs + rhs, result, file: file, line: line)
243289
XCTAssertEqual(rhs + lhs, result, file: file, line: line)
290+
XCTAssertEqual(lhs .+ rhs, result, file: file, line: line)
291+
XCTAssertEqual(rhs .+ lhs, result, file: file, line: line)
244292

245293
var complex = lhs
246294
complex += rhs
@@ -249,6 +297,14 @@ class ComplexArithmeticTests: XCTestCase {
249297
complex = rhs
250298
complex += lhs
251299
XCTAssertEqual(complex, result, file: file, line: line)
300+
301+
complex = lhs
302+
complex .+= rhs
303+
XCTAssertEqual(complex, result, file: file, line: line)
304+
305+
complex = rhs
306+
complex .+= lhs
307+
XCTAssertEqual(complex, result, file: file, line: line)
252308
}
253309

254310
private func testAddition<Scalar>(_ lhs: Complex<Scalar>, _ rhs: Scalar, _ result: Complex<Scalar>, file: StaticString = #file, line: UInt = #line) {
@@ -266,11 +322,17 @@ class ComplexArithmeticTests: XCTestCase {
266322
var complex = lhs
267323
complex -= rhs
268324
XCTAssertEqual(complex, result, file: file, line: line)
325+
326+
complex = lhs
327+
complex .-= rhs
328+
XCTAssertEqual(complex, result, file: file, line: line)
269329
}
270330

271331
private func testSubtraction<Scalar>(_ lhs: Complex<Scalar>, _ rhs: Complex<Scalar>, _ result: Complex<Scalar>, file: StaticString = #file, line: UInt = #line) where Scalar: SignedNumeric {
272332
XCTAssertEqual(lhs - rhs, result, file: file, line: line)
273333
XCTAssertEqual(rhs - lhs, -result, file: file, line: line)
334+
XCTAssertEqual(lhs .- rhs, result, file: file, line: line)
335+
XCTAssertEqual(rhs .- lhs, -result, file: file, line: line)
274336

275337
var complex = lhs
276338
complex -= rhs
@@ -279,6 +341,14 @@ class ComplexArithmeticTests: XCTestCase {
279341
complex = rhs
280342
complex -= lhs
281343
XCTAssertEqual(complex, -result, file: file, line: line)
344+
345+
complex = lhs
346+
complex .-= rhs
347+
XCTAssertEqual(complex, result, file: file, line: line)
348+
349+
complex = rhs
350+
complex .-= lhs
351+
XCTAssertEqual(complex, -result, file: file, line: line)
282352
}
283353

284354
private func testSubtraction<Scalar>(_ lhs: Complex<Scalar>, _ rhs: Scalar, _ result: Complex<Scalar>, file: StaticString = #file, line: UInt = #line) {
@@ -321,6 +391,17 @@ class ComplexArithmeticTests: XCTestCase {
321391
XCTAssertEqual(complex, result, file: file, line: line)
322392
}
323393

394+
private func testComponentwiseMultiplication<Scalar>(_ lhs: Complex<Scalar>, _ rhs: Complex<Scalar>, file: StaticString = #file, line: UInt = #line) {
395+
var result = lhs .* rhs
396+
XCTAssertEqual(result.real, lhs.real * rhs.real, file: file, line: line)
397+
XCTAssertEqual(result.imaginary, lhs.imaginary * rhs.imaginary, file: file, line: line)
398+
399+
result = lhs
400+
result .*= rhs
401+
XCTAssertEqual(result.real, lhs.real * rhs.real, file: file, line: line)
402+
XCTAssertEqual(result.imaginary, lhs.imaginary * rhs.imaginary, file: file, line: line)
403+
}
404+
324405
private func testDivision<Scalar>(_ lhs: Complex<Scalar>, _ rhs: Complex<Scalar>, _ result: Complex<Scalar>, file: StaticString = #file, line: UInt = #line) where Scalar: BinaryInteger {
325406
XCTAssertEqual(lhs / rhs, result, file: file, line: line)
326407

@@ -362,4 +443,26 @@ class ComplexArithmeticTests: XCTestCase {
362443
complex /= rhs
363444
XCTAssertEqual(complex, Complex(real: lhs.real / rhs, imaginary: lhs.imaginary / rhs), file: file, line: line)
364445
}
446+
447+
private func testComponentwiseDivision<Scalar>(_ lhs: Complex<Scalar>, _ rhs: Complex<Scalar>, file: StaticString = #file, line: UInt = #line) where Scalar: BinaryInteger {
448+
var result = lhs ./ rhs
449+
XCTAssertEqual(result.real, lhs.real / rhs.real, file: file, line: line)
450+
XCTAssertEqual(result.imaginary, lhs.imaginary / rhs.imaginary, file: file, line: line)
451+
452+
result = lhs
453+
result ./= rhs
454+
XCTAssertEqual(result.real, lhs.real / rhs.real, file: file, line: line)
455+
XCTAssertEqual(result.imaginary, lhs.imaginary / rhs.imaginary, file: file, line: line)
456+
}
457+
458+
private func testComponentwiseDivision<Scalar>(_ lhs: Complex<Scalar>, _ rhs: Complex<Scalar>, file: StaticString = #file, line: UInt = #line) where Scalar: FloatingPoint {
459+
var result = lhs ./ rhs
460+
XCTAssertEqual(result.real, lhs.real / rhs.real, file: file, line: line)
461+
XCTAssertEqual(result.imaginary, lhs.imaginary / rhs.imaginary, file: file, line: line)
462+
463+
result = lhs
464+
result ./= rhs
465+
XCTAssertEqual(result.real, lhs.real / rhs.real, file: file, line: line)
466+
XCTAssertEqual(result.imaginary, lhs.imaginary / rhs.imaginary, file: file, line: line)
467+
}
365468
}

0 commit comments

Comments
 (0)