Skip to content

Commit 2213879

Browse files
committed
Further review edits from Nate.
1 parent 8b2fd7b commit 2213879

11 files changed

+34
-40
lines changed

Sources/ComplexModule/Complex+AdditiveArithmetic.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift Numerics open source project
44
//
5-
// Copyright (c) 2019-2021 Apple Inc. and the Swift Numerics project authors
5+
// Copyright (c) 2019-2025 Apple Inc. and the Swift Numerics project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -14,7 +14,7 @@ import RealModule
1414
extension Complex: AdditiveArithmetic {
1515
/// The additive identity, with real and imaginary parts both zero.
1616
///
17-
/// See also: `one`, `i`, `infinity`
17+
/// See also: ``one``, ``i``, ``infinity``
1818
@_transparent
1919
public static var zero: Complex {
2020
Complex(0, 0)

Sources/ComplexModule/Complex+AlgebraicField.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift Numerics open source project
44
//
5-
// Copyright (c) 2019-2024 Apple Inc. and the Swift Numerics project authors
5+
// Copyright (c) 2019-2025 Apple Inc. and the Swift Numerics project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -13,6 +13,8 @@ import RealModule
1313

1414
extension Complex: AlgebraicField {
1515
/// The multiplicative identity `1 + 0i`.
16+
///
17+
/// See also: ``zero``, ``i``, ``infinity``
1618
@_transparent
1719
public static var one: Complex {
1820
Complex(1, 0)

Sources/ComplexModule/Complex+Codable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift Numerics open source project
44
//
5-
// Copyright (c) 2019 - 2021 Apple Inc. and the Swift Numerics project authors
5+
// Copyright (c) 2019-2025 Apple Inc. and the Swift Numerics project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information

Sources/ComplexModule/Complex+ElementaryFunctions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift Numerics open source project
44
//
5-
// Copyright (c) 2019-2020 Apple Inc. and the Swift Numerics project authors
5+
// Copyright (c) 2019-2025 Apple Inc. and the Swift Numerics project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information

Sources/ComplexModule/Complex+Hashable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift Numerics open source project
44
//
5-
// Copyright (c) 2019 - 2021 Apple Inc. and the Swift Numerics project authors
5+
// Copyright (c) 2019-2025 Apple Inc. and the Swift Numerics project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information

Sources/ComplexModule/Complex+IntegerLiteral.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift Numerics open source project
44
//
5-
// Copyright (c) 2019 - 2021 Apple Inc. and the Swift Numerics project authors
5+
// Copyright (c) 2019-2025 Apple Inc. and the Swift Numerics project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information

Sources/ComplexModule/Complex+Numeric.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift Numerics open source project
44
//
5-
// Copyright (c) 2019 - 2021 Apple Inc. and the Swift Numerics project authors
5+
// Copyright (c) 2019-2025 Apple Inc. and the Swift Numerics project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -43,16 +43,14 @@ extension Complex: Numeric {
4343
/// Equal to `max(abs(real), abs(imaginary))`.
4444
///
4545
/// If you need to work with the Euclidean norm (a.k.a. 2-norm) instead,
46-
/// use the `length` or `lengthSquared` properties. If you just need to
47-
/// know "how big" a number is, use this property.
46+
/// use the ``length`` or ``lengthSquared`` properties. If you just need
47+
/// to know "how big" a number is, use this property.
4848
///
4949
/// **Edge cases:**
5050
///
5151
/// - If `z` is not finite, `z.magnitude` is infinity.
5252
/// - If `z` is zero, `z.magnitude` is zero.
5353
/// - Otherwise, `z.magnitude` is finite and non-zero.
54-
///
55-
/// See also `.length` and `.lengthSquared`.
5654
@_transparent
5755
public var magnitude: RealType {
5856
guard isFinite else { return .infinity }

Sources/ComplexModule/Complex+StringConvertible.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift Numerics open source project
44
//
5-
// Copyright (c) 2019 - 2021 Apple Inc. and the Swift Numerics project authors
5+
// Copyright (c) 2019-2025 Apple Inc. and the Swift Numerics project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information

Sources/ComplexModule/Complex.swift

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift Numerics open source project
44
//
5-
// Copyright (c) 2019 - 2021 Apple Inc. and the Swift Numerics project authors
5+
// Copyright (c) 2019-2025 Apple Inc. and the Swift Numerics project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -11,11 +11,8 @@
1111

1212
import RealModule
1313

14-
/// A [complex number](https://en.wikipedia.org/wiki/Complex_number).
15-
///
16-
/// `Complex` is an `AlgebraicField`, so it has all the normal arithmetic
17-
/// operators. It conforms to `ElementaryFunctions`, so it has all the usual
18-
/// math functions.
14+
// A [complex number](https://en.wikipedia.org/wiki/Complex_number).
15+
// See Documentation.docc/Complex.md for more details.
1916
@frozen
2017
public struct Complex<RealType> where RealType: Real {
2118
// A note on the `x` and `y` properties
@@ -92,15 +89,15 @@ extension Complex {
9289
extension Complex {
9390
/// The imaginary unit.
9491
///
95-
/// See also `.zero`, `.one` and `.infinity`.
92+
/// See also ``zero``, ``one`` and ``infinity``.
9693
@_transparent
9794
public static var i: Complex {
9895
Complex(0, 1)
9996
}
10097

10198
/// The point at infinity.
10299
///
103-
/// See also `.zero`, `.one` and `.i`.
100+
/// See also ``zero``, ``one`` and ``i``.
104101
@_transparent
105102
public static var infinity: Complex {
106103
Complex(.infinity, 0)
@@ -110,7 +107,7 @@ extension Complex {
110107
///
111108
/// A complex value is finite if neither component is an infinity or nan.
112109
///
113-
/// See also `.isNormal`, `.isSubnormal` and `.isZero`.
110+
/// See also ``isNormal``, ``isSubnormal`` and ``isZero``.
114111
@_transparent
115112
public var isFinite: Bool {
116113
x.isFinite && y.isFinite
@@ -123,7 +120,7 @@ extension Complex {
123120
/// one of the components is normal if its exponent allows a full-precision
124121
/// representation.
125122
///
126-
/// See also `.isFinite`, `.isSubnormal` and `.isZero`.
123+
/// See also ``isFinite``, ``isSubnormal`` and ``isZero``.
127124
@_transparent
128125
public var isNormal: Bool {
129126
isFinite && (x.isNormal || y.isNormal)
@@ -135,7 +132,7 @@ extension Complex {
135132
/// When the result of a computation is subnormal, underflow has occurred and
136133
/// the result generally does not have full precision.
137134
///
138-
/// See also `.isFinite`, `.isNormal` and `.isZero`.
135+
/// See also ``isFinite``, ``isNormal`` and ``isZero``.
139136
@_transparent
140137
public var isSubnormal: Bool {
141138
isFinite && !isNormal && !isZero
@@ -146,7 +143,7 @@ extension Complex {
146143
/// A complex number is zero if *both* the real and imaginary components
147144
/// are zero.
148145
///
149-
/// See also `.isFinite`, `.isNormal` and `isSubnormal`.
146+
/// See also ``isFinite``, ``isNormal`` and ``isSubnormal``.
150147
@_transparent
151148
public var isZero: Bool {
152149
x == 0 && y == 0

Sources/ComplexModule/Polar.swift

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift Numerics open source project
44
//
5-
// Copyright (c) 2019 - 2021 Apple Inc. and the Swift Numerics project authors
5+
// Copyright (c) 2019-2025 Apple Inc. and the Swift Numerics project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -26,23 +26,23 @@ extension Complex {
2626
/// because the length can be as much as sqrt(2) times larger than
2727
/// either component, and thus may not be representable in the real type.
2828
///
29-
/// For most use cases, you can use the cheaper `.magnitude`
29+
/// For most use cases, you can use the cheaper ``magnitude``
3030
/// property (which computes the ∞-norm) instead, which always produces
3131
/// a representable result. See <doc:Magnitude> for more details.
3232
///
3333
/// Edge cases:
34-
/// - If a complex value is not finite, its `.length` is `infinity`.
34+
/// - If a complex value is not finite, its `length` is `infinity`.
3535
///
36-
/// See also `.magnitude`, `.lengthSquared`, `.phase`, `.polar`
37-
/// and `init(r:θ:)`.
36+
/// See also ``lengthSquared``, ``phase``, ``polar``
37+
/// and ``init(length:phase:)``.
3838
@_transparent
3939
public var length: RealType {
4040
let naive = lengthSquared
4141
guard naive.isNormal else { return carefulLength }
4242
return .sqrt(naive)
4343
}
4444

45-
// Internal implementation detail of `length`, moving slow path off
45+
// Internal implementation detail of ``length``, moving slow path off
4646
// of the inline function. Note that even `carefulLength` can overflow
4747
// for finite inputs, but only when the result is outside the range
4848
// of representable values.
@@ -54,21 +54,19 @@ extension Complex {
5454

5555
/// The squared length `(real*real + imaginary*imaginary)`.
5656
///
57-
/// This property is more efficient to compute than `length`, but is
57+
/// This property is more efficient to compute than ``length``, but is
5858
/// highly prone to overflow or underflow; for finite values that are
5959
/// not well-scaled, `lengthSquared` is often either zero or
6060
/// infinity, even when `length` is a finite number. Use this property
6161
/// only when you are certain that this value is well-scaled.
6262
///
63-
/// For many cases, `.magnitude` can be used instead, which is similarly
63+
/// For many cases, ``magnitude`` can be used instead, which is similarly
6464
/// cheap to compute and always returns a representable value.
6565
///
6666
/// Note that because of how `lengthSquared` is used, it is a primary
6767
/// design goal that it be as fast as possible. Therefore, it does not
6868
/// normalize infinities, and may return either `.infinity` or `.nan`
6969
/// for non-finite values.
70-
///
71-
/// See also ``length`` and ``magnitude``.
7270
@_transparent
7371
public var lengthSquared: RealType {
7472
x*x + y*y
@@ -93,7 +91,7 @@ extension Complex {
9391
/// - If the complex value is zero or non-finite, phase is `.nan`.
9492
/// - If the complex value is non-finite, length is `.infinity`.
9593
///
96-
/// See also: `.length`, `.phase` and `init(r:θ:)`.
94+
/// See also: ``length``, ``phase`` and ``init(length:phase:)``.
9795
public var polar: (length: RealType, phase: RealType) {
9896
(length, phase)
9997
}
@@ -116,7 +114,7 @@ extension Complex {
116114
/// ```
117115
/// - Otherwise, `θ` must be finite, or a precondition failure occurs.
118116
///
119-
/// See also `.length`, `.phase` and `.polar`.
117+
/// See also ``length``, ``phase`` and ``polar``.
120118
@inlinable
121119
public init(length: RealType, phase: RealType) {
122120
if phase.isFinite {

0 commit comments

Comments
 (0)