Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync latest package changes with Quaternions branch #228

Merged
merged 129 commits into from
Jun 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
26c51ac
Mark all complex elementary functions inlinable
stephentyrone Nov 9, 2020
198da2a
Merge pull request #165 from stephentyrone/complex-elfns-inlinable
stephentyrone Nov 9, 2020
5a7eb37
Cleaned up some comments
NevinBR Nov 11, 2020
4a2cbc1
Merge pull request #166 from NevinBR/patch-5
stephentyrone Nov 15, 2020
0cf166d
Remove zeroTangentVectorInitializer test, as the requirement has been…
stephentyrone Feb 19, 2021
105b59b
Remove vestigal C complex shims.
stephentyrone Feb 19, 2021
97852af
Adjust Float16 availability for Swift 5.4 toolchains.
stephentyrone Feb 19, 2021
6583ac7
Merge pull request #172 from stephentyrone/float16-availability
stephentyrone Feb 19, 2021
3cad9b6
Update README.md
stephentyrone Feb 22, 2021
5827f9a
80-column formatting for source doc comments
stephentyrone Mar 3, 2021
9f55a78
Merge pull request #175 from stephentyrone/eighty-columns-wide-my-fat…
stephentyrone Mar 4, 2021
d34cff5
Remove .xcodesamplecode.plist, which prevents editing markdown from X…
Mar 19, 2021
50161d3
remove workflows, no longer needed.
stephentyrone Mar 21, 2021
2aa93cc
Merge pull request #179 from stephentyrone/remove-workflows
stephentyrone Mar 21, 2021
f50a1ac
Merge pull request #178 from kylemacomber/remove-xcodesamplecode-plist
stephentyrone Mar 23, 2021
702c6fc
Document the Augmented enum in RealModule in advance of 1.0
stephentyrone Aug 19, 2021
17f5b59
Merge pull request #181 from stephentyrone/document-augmented-arithmetic
stephentyrone Aug 19, 2021
faf1377
Add some documentation for AlgebraicField ops, minor fix for Augmented.
stephentyrone Aug 19, 2021
d7e692e
Merge pull request #182 from stephentyrone/more-documentation-for-1.0
stephentyrone Aug 19, 2021
10e75aa
Further expand documentation of `reciprocal` with some example use.
stephentyrone Aug 20, 2021
ecc7788
Update Sources/ComplexModule/Arithmetic.swift
stephentyrone Aug 20, 2021
342d38e
Update Sources/RealModule/AlgebraicField.swift
stephentyrone Aug 20, 2021
0544047
Update Sources/ComplexModule/Arithmetic.swift
stephentyrone Aug 20, 2021
32f48e6
Update Sources/RealModule/Real.swift
stephentyrone Aug 20, 2021
3a5c739
Update Sources/RealModule/Real.swift
stephentyrone Aug 20, 2021
12148ff
Update Sources/RealModule/Real.swift
stephentyrone Aug 20, 2021
3d6bff6
Update README.md
stephentyrone Aug 20, 2021
ac7a9a9
Merge pull request #185 from stephentyrone/reciprocal-documentation
stephentyrone Aug 20, 2021
32c2b64
Merge pull request #186 from apple/complex-readme
stephentyrone Aug 20, 2021
988f1e1
Remove Real and Complex _libraries_; keep modules.
stephentyrone Aug 25, 2021
97dfcff
Merge pull request #187 from apple/remove-sub-libraries
stephentyrone Aug 25, 2021
84474a3
Initial setup of IntegerUtilities module.
stephentyrone Aug 25, 2021
4a6730b
Merge pull request #188 from stephentyrone/rotate
stephentyrone Aug 26, 2021
909a77c
Create GCD.swift
NevinBR Aug 26, 2021
632919c
Create GCDTests.swift
NevinBR Aug 26, 2021
996cf7f
CMake build support for the IntegerUtilities module.
stephentyrone Aug 26, 2021
e29479b
Merge pull request #190 from stephentyrone/cmake-integer-utilities
stephentyrone Aug 26, 2021
4fbcb11
Improved GCD documentation
NevinBR Aug 26, 2021
21ff6d3
Revert "Remove Real and Complex _libraries_; keep modules."
stephentyrone Aug 27, 2021
b68a81d
Merge pull request #191 from apple/revert-187-remove-sub-libraries
stephentyrone Aug 27, 2021
b9415c9
Add missing IntegerUtilities dependency for Numerics module
stephentyrone Aug 27, 2021
0289df5
Merge pull request #192 from apple/add-integer-utilities-dependency
stephentyrone Aug 27, 2021
b8f4521
Made gcd a free function
NevinBR Aug 30, 2021
83c378f
Update GCDTests.swift
NevinBR Aug 30, 2021
67af2fe
Simplified gcd implementation
NevinBR Aug 30, 2021
89c4e42
Added tests for gcd overflow on Int.min
NevinBR Aug 31, 2021
8552bec
Documented overflow behavior of gcd
NevinBR Aug 31, 2021
63edd67
Update README for 1.0.0.
stephentyrone Aug 31, 2021
5f28ad0
Explicitly exclude CMakeLists.txt and README.md files from all targets.
stephentyrone Aug 31, 2021
7738390
Merge pull request #196 from stephentyrone/excluded-filenames
stephentyrone Aug 31, 2021
b505d3c
Merge pull request #198 from stephentyrone/clarify-stability-differen…
stephentyrone Aug 31, 2021
85264c8
Reworded doc comment for `gcd`
NevinBR Sep 10, 2021
bd68569
Commented out `ExpectFailure` tests for `gcd`
NevinBR Sep 10, 2021
f2cfa8d
Fixed typo
NevinBR Sep 10, 2021
9d84cef
Merge pull request #189 from NevinBR/patch-6
stephentyrone Sep 10, 2021
ae38370
Fix typo in AlgebraicField documentation
Saklad5 Sep 17, 2021
b6f4c44
Merge pull request #200 from Saklad5/patch-1
stephentyrone Sep 20, 2021
abb8998
resolve warnings in 5.5 tools build, add skeleton readme for integer …
stephentyrone Sep 20, 2021
e22ff86
Add GCD files to CMake build.
stephentyrone Sep 20, 2021
bc17ae6
Merge pull request #201 from stephentyrone/integer-utils-readme
stephentyrone Sep 20, 2021
c3806f2
Removed number lines for easy clipboard copying.
RahulBhalley Sep 25, 2021
caca93c
Merge pull request #202 from RahulBhalley/patch-1
stephentyrone Sep 26, 2021
c124585
Skeleton of integer shift with rounding.
stephentyrone Sep 22, 2021
d78c067
Some documentation work.
stephentyrone Sep 26, 2021
eeaf9e3
More rounding mode documentation.
stephentyrone Sep 27, 2021
92eb762
Cursory documentation for shifted(right:).
stephentyrone Sep 27, 2021
cddd5e6
Re-arrange some things.
stephentyrone Sep 27, 2021
dec7339
Renamed RoundingMode.trap to .requireExact
stephentyrone Sep 28, 2021
9837c10
Update README.md to refer to 1.0.0 instead of 0.1.0
stephentyrone Oct 2, 2021
501f582
Added division with rounding operations.
stephentyrone Oct 12, 2021
63df367
Fix a typo in the comments of sinh expression
markuswntr Oct 13, 2021
1b3e3f1
Merge pull request #207 from markuswntr/patch-1
stephentyrone Oct 13, 2021
710ca08
Renamed shifted(right:) to shifted(rightBy:).
stephentyrone Oct 13, 2021
3eaa0b3
Additional documentation for division/shift with rounding
stephentyrone Oct 13, 2021
24d8f51
Add tests for remainder(dividingBy: -1).
stephentyrone Oct 14, 2021
0acd49c
Take advantage of GFM footnotes in the README.
stephentyrone Oct 14, 2021
b37b64d
Update README.md
stephentyrone Oct 14, 2021
9c4bd83
Update README.md
stephentyrone Oct 14, 2021
43e1d4d
Update README.md
stephentyrone Oct 14, 2021
af53934
Add note that integer utilities isn't stable yet.
stephentyrone Oct 14, 2021
f956c23
Merge pull request #203 from stephentyrone/rounding
stephentyrone Oct 15, 2021
1e72483
Add twoSum to augmented arithmetic
markuswntr Oct 20, 2021
34a7550
Merge branch 'main' into quaternion/sync
markuswntr Oct 21, 2021
8b05d1c
Update comments on the difference of sum(_:_:) and sum(large:small:)
markuswntr Oct 21, 2021
f6e5563
Fix argument ordering in twoSum and add test cases
markuswntr Oct 26, 2021
d4a440f
Update range of random values in test cases
markuswntr Oct 26, 2021
6ec74ec
Fix source code formatting
markuswntr Oct 27, 2021
05366d7
Revert names of temporary variables
markuswntr Oct 27, 2021
c74d817
Merge pull request #208 from markuswntr/two-sum
stephentyrone Oct 27, 2021
be0534a
Add the `DoubleWidth` type
benrimmington Oct 27, 2021
b501ca4
Merge pull request #197 from benrimmington/experimental
stephentyrone Oct 27, 2021
944ae70
Merge branch 'main' into quaternion/sync
markuswntr Oct 28, 2021
db932c9
Remove big/little endiant distinction in representation of DoubleWidth
stephentyrone Nov 3, 2021
84044a8
Merge pull request #209 from stephentyrone/unnecessary-endian
stephentyrone Nov 3, 2021
cdb092b
Expand some comments on DoubleWidth basic properties and inits.
stephentyrone Nov 3, 2021
9e50430
Merge pull request #210 from stephentyrone/double-width-comments
stephentyrone Nov 3, 2021
48099a0
Clean out some unnecessary stuff in DoubleWidth.
stephentyrone Nov 3, 2021
80d758a
Merge pull request #211 from stephentyrone/further-doublewidth-cleanup
stephentyrone Nov 3, 2021
bfd905c
Minor cleanups in integer utilities.
stephentyrone Nov 3, 2021
f5b33a6
Merge pull request #212 from stephentyrone/integer-utils-cleanup
stephentyrone Nov 9, 2021
8983be8
add arm64 support for M1 Mac
DanboDuan Nov 17, 2021
f3365bd
Merge pull request #213 from DanboDuan/main
stephentyrone Nov 18, 2021
47a2337
Use DoubleWidth in stochastic rounding right-shift tests.
stephentyrone Nov 24, 2021
1939f34
Merge pull request #217 from stephentyrone/double-width-testing-right…
stephentyrone Nov 24, 2021
ba65b0f
Refactor Complex module for finer granularity.
stephentyrone Dec 11, 2021
d329698
remove F16/F80 stubs for complex elfns.
stephentyrone Dec 11, 2021
9596f40
Merge pull request #219 from stephentyrone/refactor-complex
stephentyrone Dec 16, 2021
445b0da
Update complex cmake for refactoring.
stephentyrone Dec 16, 2021
4ce74b4
Merge pull request #220 from stephentyrone/refactor-complex-cmake
stephentyrone Dec 16, 2021
7f2d022
GCD bug fix
NevinBR Feb 22, 2022
c4f8886
Move baseline supported tools version to 5.4.
stephentyrone Mar 5, 2022
27f8192
Attempt to work around CI misconfiguration by removing Complex Differ…
stephentyrone Apr 6, 2022
5bbf0e2
Merge pull request #223 from stephentyrone/require-swift-5.4
stephentyrone Apr 6, 2022
b6018fa
Merge pull request #222 from NevinBR/patch-1
stephentyrone Apr 6, 2022
270972d
Minor documentation formatting cleanup.
stephentyrone Apr 6, 2022
fc1b2d1
Merge pull request #224 from apple/documentation-formatting
stephentyrone Apr 6, 2022
027bcc5
Remove conformance of Complex to Differentiable
stephentyrone Apr 6, 2022
cc53a7b
Make _NumericsShims a systemLibrary target.
stephentyrone Apr 6, 2022
5803eaf
Let's try a different approach.
stephentyrone Apr 7, 2022
56db9b5
Merge pull request #225 from apple/remove-differentiable
stephentyrone Apr 7, 2022
48003e8
Fixup banner comment on Scale.swift.
stephentyrone Apr 7, 2022
1db31eb
Link math library on Android too
finagolfin Apr 7, 2022
0d9f0b2
Update CMakeLists.txt
compnerd Apr 7, 2022
98a8a16
Merge pull request #226 from compnerd/patch-1
stephentyrone Apr 7, 2022
0dc8fef
Merge pull request #227 from buttaface/math
stephentyrone Apr 8, 2022
8ada4cf
Merge branch 'quaternions' into quaternion/sync
markuswntr Apr 26, 2022
964e62c
Merge branch 'main' into quaternion/sync
markuswntr Apr 26, 2022
f56d2cb
Sync quaternion module structure with complex module
markuswntr Apr 26, 2022
4f97344
Fix header documentation
markuswntr Apr 26, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions .github/workflows/macos.yml

This file was deleted.

5 changes: 0 additions & 5 deletions .xcodesamplecode.plist

This file was deleted.

107 changes: 87 additions & 20 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// swift-tools-version:5.0
// swift-tools-version:5.4
//===--- Package.swift ----------------------------------------*- swift -*-===//
//
// This source file is part of the Swift Numerics open source project
//
// Copyright (c) 2019 Apple Inc. and the Swift Numerics project authors
// Copyright (c) 2019-2021 Apple Inc. and the Swift Numerics project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
Expand All @@ -12,6 +12,8 @@

import PackageDescription

let excludedFilenames = ["CMakeLists.txt", "README.md"]

let package = Package(

name: "swift-numerics",
Expand All @@ -23,23 +25,88 @@ let package = Package(
],

targets: [
// User-facing modules
.target(name: "ComplexModule", dependencies: ["RealModule"]),
.target(name: "Numerics", dependencies: ["ComplexModule", "QuaternionModule", "RealModule"]),
.target(name: "QuaternionModule", dependencies: ["RealModule"]),
.target(name: "RealModule", dependencies: ["_NumericsShims"]),

// Implementation details
.target(name: "_NumericsShims", dependencies: []),
.target(name: "_TestSupport", dependencies: ["Numerics"]),

// Unit test bundles
.testTarget(name: "ComplexTests", dependencies: ["_TestSupport"]),
.testTarget(name: "QuaternionTests", dependencies: ["_TestSupport"]),
.testTarget(name: "RealTests", dependencies: ["_TestSupport"]),

// Test executables
.target(name: "ComplexLog", dependencies: ["Numerics", "_TestSupport"], path: "Tests/Executable/ComplexLog"),
.target(name: "ComplexLog1p", dependencies: ["Numerics", "_TestSupport"], path: "Tests/Executable/ComplexLog1p")
// MARK: - Public API
.target(
name: "ComplexModule",
dependencies: ["RealModule"],
exclude: excludedFilenames
),

.target(
name: "IntegerUtilities",
dependencies: [],
exclude: excludedFilenames
),

.target(
name: "Numerics",
dependencies: [
"ComplexModule", "IntegerUtilities",
"QuaternionModule", "RealModule"
],
exclude: excludedFilenames
),

.target(
name: "QuaternionModule",
dependencies: ["RealModule"],
exclude: ["README.md", "Transformation.md"]
),

.target(
name: "RealModule",
dependencies: ["_NumericsShims"],
exclude: excludedFilenames
),

// MARK: - Implementation details
.target(
name: "_NumericsShims",
exclude: excludedFilenames,
linkerSettings: [.linkedLibrary("m", .when(platforms: [.linux, .android]))]
),

.target(
name: "_TestSupport",
dependencies: ["Numerics"],
exclude: ["CMakeLists.txt"]
),

// MARK: - Unit test bundles
.testTarget(
name: "ComplexTests",
dependencies: ["_TestSupport"],
exclude: ["CMakeLists.txt"]
),

.testTarget(
name: "IntegerUtilitiesTests",
dependencies: ["IntegerUtilities", "_TestSupport"],
exclude: ["CMakeLists.txt"]
),

.testTarget(
name: "QuaternionTests",
dependencies: ["_TestSupport"]
),

.testTarget(
name: "RealTests",
dependencies: ["_TestSupport"],
exclude: ["CMakeLists.txt"]
),

// MARK: - Test executables
.executableTarget(
name: "ComplexLog",
dependencies: ["Numerics", "_TestSupport"],
path: "Tests/Executable/ComplexLog"
),

.executableTarget(
name: "ComplexLog1p",
dependencies: ["Numerics", "_TestSupport"],
path: "Tests/Executable/ComplexLog1p"
)
]
)
71 changes: 43 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ These modules fall broadly into two categories:
There is some overlap between these two categories, and an API that begins in the first category may migrate into the second as it matures and new uses are discovered.

Swift Numerics modules are fine-grained.
For example, if you need support for Complex numbers, you can import ComplexModule¹ as a standalone module:
For example, if you need support for Complex numbers, you can import ComplexModule[^1] as a standalone module:

```swift
import ComplexModule
Expand Down Expand Up @@ -42,7 +42,7 @@ To use Swift Numerics in a SwiftPM project:
1. Add the following line to the dependencies in your `Package.swift` file:

```swift
.package(url: "https://github.com/apple/swift-numerics", from: "0.0.7"),
.package(url: "https://github.com/apple/swift-numerics", from: "1.0.0"),
```

2. Add `Numerics` as a dependency for your target:
Expand All @@ -56,6 +56,22 @@ To use Swift Numerics in a SwiftPM project:

3. Add `import Numerics` in your source code.

## Source stability

The Swift Numerics package is source stable; version numbers follow [Semantic Versioning](https://semver.org).
The public API of the `swift-numerics` package consists of non-underscored declarations that are marked either `public` or `usableFromInline` in modules re-exported by the top-level `Numerics` module.
Interfaces that aren't part of the public API may continue to change in any release, including patch releases.

Note that contents of the `_NumericsShims` and `_TestSupport` modules, as well as contents of the `Tests` directory, explicitly are not public API.
The definitions therein may therefore change at whim, and the entire module may be removed in any new release.
If you have a use case that requires underscored operations, please raise an issue to request that they be made public API.

Future minor versions of the package may introduce changes to these rules as needed.

We'd like this package to quickly embrace Swift language and toolchain improvements that are relevant to its mandate.
Accordingly, from time to time, we expect that new versions of this package will require clients to upgrade to a more recent Swift toolchain release.
Requiring a new Swift release will only require a minor version bump.

## Contributing to Swift Numerics

Swift Numerics is a standalone library that is separate from the core Swift project, but it will sometimes act as a staging ground for APIs that will later be incorporated into the Swift Standard Library.
Expand Down Expand Up @@ -89,7 +105,8 @@ Questions about how to use Swift Numerics modules, or issues that are not clearl

1. [`RealModule`](Sources/RealModule/README.md)
2. [`ComplexModule`](Sources/ComplexModule/README.md)
3. [`QuaternionModule`](Sources/QuaternionModule/README.md)
3. [`IntegerUtilities`](Sources/IntegerUtilties/README.md) (on main only, not yet present in a released tag)
4. [`QuaternionModule`](Sources/QuaternionModule/README.md)

## Future expansion

Expand All @@ -98,28 +115,26 @@ Questions about how to use Swift Numerics modules, or issues that are not clearl
3. [Shaped Arrays](https://github.com/apple/swift-numerics/issues/6)
4. [Decimal Floating-point](https://github.com/apple/swift-numerics/issues/7)

## Notes

¹ Swift is currently unable to use the fully-qualified name for types when a type and module have the same name (discussion here: https://forums.swift.org/t/pitch-fully-qualified-name-syntax/28482).
This would prevent users of Swift Numerics who don't need generic types from doing things such as:

```swift
import Complex
// I know I only ever want Complex<Double>, so I shouldn't need the generic parameter.
typealias Complex = Complex.Complex<Double> // This doesn't work, because name lookup fails.
```

For this reason, modules that would have this ambiguity are suffixed with `Module` within Swift Numerics:

```swift
import ComplexModule
// I know I only ever want Complex<Double>, so I shouldn't need the generic parameter.
typealias Complex = ComplexModule.Complex<Double>
// But I can still refer to the generic type by qualifying the name if I need it occasionally:
let a = ComplexModule.Complex<Float>
```

The `Real` module does not contain a `Real` type, but does contain a `Real` protocol.
Users may want to define their own `Real` type (and possibly re-export the `Real` module)--that is why the suffix is also applied there.
New modules have to evaluate this decision carefully, but can err on the side of adding the suffix.
It's expected that most users will simply `import Numerics`, so this isn't an issue for them.
[^1]: The module is named `ComplexModule` instead of `Complex` because Swift is currently unable to use the fully-qualified name for types when a type and module have the same name (discussion here: https://forums.swift.org/t/pitch-fully-qualified-name-syntax/28482).
This would prevent users of Swift Numerics who don't need generic types from doing things such as:

```swift
import Complex
// I know I only ever want Complex<Double>, so I shouldn't need the generic parameter.
typealias Complex = Complex.Complex<Double> // This doesn't work, because name lookup fails.
```

For this reason, modules that would have this ambiguity are suffixed with `Module` within Swift Numerics:

```swift
import ComplexModule
// I know I only ever want Complex<Double>, so I shouldn't need the generic parameter.
typealias Complex = ComplexModule.Complex<Double>
// But I can still refer to the generic type by qualifying the name if I need it occasionally:
let a = ComplexModule.Complex<Float>
```

The `Real` module does not contain a `Real` type, but does contain a `Real` protocol.
Users may want to define their own `Real` type (and possibly re-export the `Real` module)--that is why the suffix is also applied there.
New modules have to evaluate this decision carefully, but can err on the side of adding the suffix.
It's expected that most users will simply `import Numerics`, so this isn't an issue for them.
3 changes: 2 additions & 1 deletion Sources/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#[[
This source file is part of the Swift Numerics open source project
Copyright (c) 2019 Apple Inc. and the Swift Numerics project authors
Copyright (c) 2019-2021 Apple Inc. and the Swift Numerics project authors
Licensed under Apache License v2.0 with Runtime Library Exception
See https://swift.org/LICENSE.txt for license information
#]]

add_subdirectory(_NumericsShims)
add_subdirectory(ComplexModule)
add_subdirectory(IntegerUtilities)
add_subdirectory(Numerics)
add_subdirectory(RealModule)
if(BUILD_TESTING)
Expand Down
13 changes: 10 additions & 3 deletions Sources/ComplexModule/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,17 @@ See https://swift.org/LICENSE.txt for license information
#]]

add_library(ComplexModule
Arithmetic.swift
Complex.swift
Differentiable.swift
ElementaryFunctions.swift)
Complex+AdditiveArithmetic.swift
Complex+AlgebraicField.swift
Complex+Codable.swift
Complex+ElementaryFunctions.swift
Complex+Hashable.swift
Complex+IntegerLiteral.swift
Complex+Numeric.swift
Complex+StringConvertible.swift
Polar.swift
Scale.swift)
set_target_properties(ComplexModule PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
target_link_libraries(ComplexModule PUBLIC
Expand Down
42 changes: 42 additions & 0 deletions Sources/ComplexModule/Complex+AdditiveArithmetic.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//===--- Complex+AdditiveArithmetic.swift ---------------------*- swift -*-===//
//
// This source file is part of the Swift Numerics open source project
//
// Copyright (c) 2019-2021 Apple Inc. and the Swift Numerics project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
//
//===----------------------------------------------------------------------===//

import RealModule

extension Complex: AdditiveArithmetic {
/// The additive identity, with real and imaginary parts both zero.
///
/// See also: `one`, `i`, `infinity`
@_transparent
public static var zero: Complex {
Complex(0, 0)
}

@_transparent
public static func +(z: Complex, w: Complex) -> Complex {
return Complex(z.x + w.x, z.y + w.y)
}

@_transparent
public static func -(z: Complex, w: Complex) -> Complex {
return Complex(z.x - w.x, z.y - w.y)
}

@_transparent
public static func +=(z: inout Complex, w: Complex) {
z = z + w
}

@_transparent
public static func -=(z: inout Complex, w: Complex) {
z = z - w
}
}
Loading