Skip to content

Commit 270972d

Browse files
committed
Minor documentation formatting cleanup.
1 parent b6018fa commit 270972d

10 files changed

+78
-261
lines changed

Sources/ComplexModule/Complex+AlgebraicField.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ extension Complex: AlgebraicField {
111111
/// ```
112112
///
113113
/// Error Bounds:
114-
/// -
114+
///
115115
/// Unlike real types, when working with complex types, multiplying by the
116116
/// reciprocal instead of dividing cannot change the result. If the
117117
/// reciprocal is non-nil, the two computations are always equivalent.

Sources/ComplexModule/Complex+Numeric.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ extension Complex: Numeric {
4747
/// - If `z` is zero, `z.magnitude` is `0`.
4848
/// - Otherwise, `z.magnitude` is finite and non-zero.
4949
///
50-
/// See also:
51-
/// - `.length`
52-
/// - `.lengthSquared`
50+
/// See also `.length` and `.lengthSquared`.
5351
@_transparent
5452
public var magnitude: RealType {
5553
guard isFinite else { return .infinity }

Sources/ComplexModule/Complex.swift

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import RealModule
1616
/// TODO: introductory text on complex numbers
1717
///
1818
/// Implementation notes:
19-
/// -
19+
///
2020
/// This type does not provide heterogeneous real/complex arithmetic,
2121
/// not even the natural vector-space operations like real * complex.
2222
/// There are two reasons for this choice: first, Swift broadly avoids
@@ -105,23 +105,15 @@ extension Complex {
105105
extension Complex {
106106
/// The imaginary unit.
107107
///
108-
/// See also:
109-
/// -
110-
/// - .zero
111-
/// - .one
112-
/// - .infinity
108+
/// See also `.zero`, `.one` and `.infinity`.
113109
@_transparent
114110
public static var i: Complex {
115111
Complex(0, 1)
116112
}
117113

118114
/// The point at infinity.
119115
///
120-
/// See also:
121-
/// -
122-
/// - .zero
123-
/// - .one
124-
/// - .i
116+
/// See also `.zero`, `.one` and `.i`.
125117
@_transparent
126118
public static var infinity: Complex {
127119
Complex(.infinity, 0)
@@ -131,11 +123,7 @@ extension Complex {
131123
///
132124
/// A complex value is finite if neither component is an infinity or nan.
133125
///
134-
/// See also:
135-
/// -
136-
/// - `.isNormal`
137-
/// - `.isSubnormal`
138-
/// - `.isZero`
126+
/// See also `.isNormal`, `.isSubnormal` and `.isZero`.
139127
@_transparent
140128
public var isFinite: Bool {
141129
x.isFinite && y.isFinite
@@ -148,10 +136,7 @@ extension Complex {
148136
/// one of the components is normal if its exponent allows a full-precision
149137
/// representation.
150138
///
151-
/// See also:
152-
/// - `.isFinite`
153-
/// - `.isSubnormal`
154-
/// - `.isZero`
139+
/// See also `.isFinite`, `.isSubnormal` and `.isZero`.
155140
@_transparent
156141
public var isNormal: Bool {
157142
isFinite && (x.isNormal || y.isNormal)
@@ -163,10 +148,7 @@ extension Complex {
163148
/// When the result of a computation is subnormal, underflow has occurred and
164149
/// the result generally does not have full precision.
165150
///
166-
/// See also:
167-
/// - `.isFinite`
168-
/// - `.isNormal`
169-
/// - `.isZero`
151+
/// See also `.isFinite`, `.isNormal` and `.isZero`.
170152
@_transparent
171153
public var isSubnormal: Bool {
172154
isFinite && !isNormal && !isZero
@@ -177,11 +159,7 @@ extension Complex {
177159
/// A complex number is zero if *both* the real and imaginary components
178160
/// are zero.
179161
///
180-
/// See also:
181-
/// -
182-
/// - `.isFinite`
183-
/// - `.isNormal`
184-
/// - `.isSubnormal`
162+
/// See also `.isFinite`, `.isNormal` and `isSubnormal`.
185163
@_transparent
186164
public var isZero: Bool {
187165
x == 0 && y == 0

Sources/ComplexModule/Polar.swift

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,10 @@ extension Complex {
3131
/// a representable result.
3232
///
3333
/// Edge cases:
34-
/// -
35-
/// If a complex value is not finite, its `.length` is `infinity`.
36-
///
37-
/// See also:
38-
/// -
39-
/// - `.magnitude`
40-
/// - `.lengthSquared`
41-
/// - `.phase`
42-
/// - `.polar`
43-
/// - `init(r:θ:)`
34+
/// - If a complex value is not finite, its `.length` is `infinity`.
35+
///
36+
/// See also `.magnitude`, `.lengthSquared`, `.phase`, `.polar`
37+
/// and `init(r:θ:)`.
4438
@_transparent
4539
public var length: RealType {
4640
let naive = lengthSquared
@@ -69,10 +63,7 @@ extension Complex {
6963
/// For many cases, `.magnitude` can be used instead, which is similarly
7064
/// cheap to compute and always returns a representable value.
7165
///
72-
/// See also:
73-
/// -
74-
/// - `.length`
75-
/// - `.magnitude`
66+
/// See also `.length` and `.magnitude`.
7667
@_transparent
7768
public var lengthSquared: RealType {
7869
x*x + y*y
@@ -88,14 +79,9 @@ extension Complex {
8879
/// and `nan` is returned.
8980
///
9081
/// Edge cases:
91-
/// -
92-
/// If the complex value is zero or non-finite, phase is `nan`.
93-
///
94-
/// See also:
95-
/// -
96-
/// - `.length`
97-
/// - `.polar`
98-
/// - `init(r:θ:)`
82+
/// - If the complex value is zero or non-finite, phase is `nan`.
83+
///
84+
/// See also `.length`, `.polar` and `init(r:θ:)`.
9985
@inlinable
10086
public var phase: RealType {
10187
guard isFinite && !isZero else { return .nan }
@@ -105,23 +91,17 @@ extension Complex {
10591
/// The length and phase (or polar coordinates) of this value.
10692
///
10793
/// Edge cases:
108-
/// -
109-
/// If the complex value is zero or non-finite, phase is `.nan`.
110-
/// If the complex value is non-finite, length is `.infinity`.
111-
///
112-
/// See also:
113-
/// -
114-
/// - `.length`
115-
/// - `.phase`
116-
/// - `init(r:θ:)`
94+
/// - If the complex value is zero or non-finite, phase is `.nan`.
95+
/// - If the complex value is non-finite, length is `.infinity`.
96+
///
97+
/// See also: `.length`, `.phase` and `init(r:θ:)`.
11798
public var polar: (length: RealType, phase: RealType) {
11899
(length, phase)
119100
}
120101

121102
/// Creates a complex value specified with polar coordinates.
122103
///
123104
/// Edge cases:
124-
/// -
125105
/// - Negative lengths are interpreted as reflecting the point through the
126106
/// origin, i.e.:
127107
/// ```
@@ -137,11 +117,7 @@ extension Complex {
137117
/// ```
138118
/// - Otherwise, `θ` must be finite, or a precondition failure occurs.
139119
///
140-
/// See also:
141-
/// -
142-
/// - `.length`
143-
/// - `.phase`
144-
/// - `.polar`
120+
/// See also `.length`, `.phase` and `.polar`.
145121
@inlinable
146122
public init(length: RealType, phase: RealType) {
147123
if phase.isFinite {

Sources/RealModule/AlgebraicField.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,7 @@
3737
/// If a type `T` conforms to the `Real` protocol, then `T` and `Complex<T>`
3838
/// both conform to `AlgebraicField`.
3939
///
40-
/// See Also:
41-
/// -
42-
/// - Real
43-
/// - SignedNumeric
44-
/// - Numeric
45-
/// - AdditiveArithmetic
40+
/// See also `Real`, `SignedNumeric`, `Numeric` and `AdditiveArithmetic`.
4641
///
4742
/// [field]: https://en.wikipedia.org/wiki/Field_(mathematics)
4843
public protocol AlgebraicField: SignedNumeric {

Sources/RealModule/ApproximateEquality.swift

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ extension Numeric where Magnitude: FloatingPoint {
2828
/// is not suitable for all use cases.
2929
///
3030
/// Mathematical Properties:
31-
/// ------------------------
32-
///
31+
///
3332
/// - `isApproximatelyEqual(to:relativeTolerance:norm:)` is _reflexive_ for
3433
/// non-exceptional values (such as NaN).
3534
///
@@ -51,9 +50,7 @@ extension Numeric where Magnitude: FloatingPoint {
5150
/// so long as no underflow or overflow has occured, and no exceptional
5251
/// value is produced by the scaling.
5352
///
54-
/// See Also:
55-
/// -------
56-
/// - `isApproximatelyEqual(to:absoluteTolerance:[relativeTolerance:norm:])`
53+
/// See also `isApproximatelyEqual(to:absoluteTolerance:[relativeTolerance:norm:])`.
5754
///
5855
/// - Parameters:
5956
///
@@ -98,7 +95,6 @@ extension Numeric where Magnitude: FloatingPoint {
9895
/// where `scale` is `max(self.magnitude, other.magnitude)`.
9996
///
10097
/// Mathematical Properties:
101-
/// ------------------------
10298
///
10399
/// - `isApproximatelyEqual(to:absoluteTolerance:relativeTolerance:)`
104100
/// is _reflexive_ for non-exceptional values (such as NaN).
@@ -118,9 +114,7 @@ extension Numeric where Magnitude: FloatingPoint {
118114
/// to `a` is _convex_. (Under the assumption that `norm` implements a
119115
/// valid norm, which cannot be checked by this function.)
120116
///
121-
/// See Also:
122-
/// -------
123-
/// - `isApproximatelyEqual(to:[relativeTolerance:])`
117+
/// See also `isApproximatelyEqual(to:[relativeTolerance:])`.
124118
///
125119
/// - Parameters:
126120
///
@@ -170,7 +164,6 @@ extension AdditiveArithmetic {
170164
/// where `scale` is `max(norm(self), norm(other))`.
171165
///
172166
/// Mathematical Properties:
173-
/// ------------------------
174167
///
175168
/// - `isApproximatelyEqual(to:absoluteTolerance:relativeTolerance:norm:)`
176169
/// is _reflexive_ for non-exceptional values (such as NaN).
@@ -191,10 +184,8 @@ extension AdditiveArithmetic {
191184
/// to `a` is _convex_ (under the assumption that `norm` implements a
192185
/// valid norm, which cannot be checked by this function or a protocol).
193186
///
194-
/// See Also:
195-
/// -------
196-
/// - `isApproximatelyEqual(to:[relativeTolerance:norm:])`
197-
/// - `isApproximatelyEqual(to:absoluteTolerance:[relativeTolerance:])`
187+
/// See also `isApproximatelyEqual(to:[relativeTolerance:norm:])` and
188+
/// `isApproximatelyEqual(to:absoluteTolerance:[relativeTolerance:])`.
198189
///
199190
/// - Parameters:
200191
///

Sources/RealModule/AugmentedArithmetic.swift

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ extension Augmented {
2828
/// This operation is sometimes called "twoProd" or "twoProduct".
2929
///
3030
/// Edge Cases:
31-
/// -
31+
///
3232
/// - `head` is always the IEEE 754 product `a * b`.
3333
/// - If `head` is not finite, `tail` is unspecified and should not be
3434
/// interpreted as having any meaning (it may be `NaN` or `infinity`).
@@ -39,7 +39,7 @@ extension Augmented {
3939
/// - If `head` is zero, `tail` is also a zero with unspecified sign.
4040
///
4141
/// Postconditions:
42-
/// -
42+
///
4343
/// - If `head` is normal, then `abs(tail) < head.ulp`.
4444
/// Assuming IEEE 754 default rounding, `abs(tail) <= head.ulp/2`.
4545
/// - If both `head` and `tail` are normal, then `a * b` is exactly
@@ -61,8 +61,7 @@ extension Augmented {
6161
/// value.
6262
///
6363
/// Unlike `Augmented.product(a, b)`, the rounding error of a sum can
64-
/// never underflow. However, it may not be exactly representable when
65-
/// `a` and `b` differ widely in magnitude.
64+
/// never underflow.
6665
///
6766
/// This operation is sometimes called ["fastTwoSum"].
6867
///
@@ -71,19 +70,19 @@ extension Augmented {
7170
/// - b: The summand with smaller magnitude.
7271
///
7372
/// Preconditions:
74-
/// -
73+
///
7574
/// - `large.magnitude` must not be smaller than `small.magnitude`.
7675
/// They may be equal, or one or both may be `NaN`.
7776
/// This precondition is only enforced in debug builds.
7877
///
7978
/// Edge Cases:
80-
/// -
79+
///
8180
/// - `head` is always the IEEE 754 sum `a + b`.
8281
/// - If `head` is not finite, `tail` is unspecified and should not be
8382
/// interpreted as having any meaning (it may be `NaN` or `infinity`).
8483
///
8584
/// Postconditions:
86-
/// -
85+
///
8786
/// - If `head` is normal, then `abs(tail) < head.ulp`.
8887
/// Assuming IEEE 754 default rounding, `abs(tail) <= head.ulp/2`.
8988
///
@@ -112,8 +111,7 @@ extension Augmented {
112111
/// over this function; as it faster to calculate.
113112
///
114113
/// Unlike `Augmented.product(a, b)`, the rounding error of a sum can
115-
/// never underflow. However, it may not be exactly representable when
116-
/// `a` and `b` differ widely in magnitude.
114+
/// never underflow.
117115
///
118116
/// This operation is sometimes called ["twoSum"].
119117
///
@@ -122,13 +120,13 @@ extension Augmented {
122120
/// - b: The other summand
123121
///
124122
/// Edge Cases:
125-
/// -
123+
///
126124
/// - `head` is always the IEEE 754 sum `a + b`.
127125
/// - If `head` is not finite, `tail` is unspecified and should not be
128126
/// interpreted as having any meaning (it may be `NaN` or `infinity`).
129127
///
130128
/// Postconditions:
131-
/// -
129+
///
132130
/// - If `head` is normal, then `abs(tail) < head.ulp`.
133131
/// Assuming IEEE 754 default rounding, `abs(tail) <= head.ulp/2`.
134132
///

0 commit comments

Comments
 (0)